🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Int32
This page was created by Stephanie on 2023-05-19. Last edited by Wikiadmin on 2026-07-29.

You use Int32 for class attributes and OCL expressions that need whole-number values, including negative values, within the 32-bit signed integer range.

What Int32 represents

Int32 means 32-bit signed integer. It stores whole numbers: numbers without a fractional part.

An Int32 value can be from -2,147,483,648 through 2,147,483,647. The value 0 is valid, as are positive and negative values.

Use Int32 when the value is naturally a count, position, identifier, or other whole-number quantity that fits this range.

Example value Valid Int32? Typical use
42 Yes A quantity or sequence number
-3 Yes A signed adjustment or offset
12.5 No Requires a type that supports fractional values
3000000000 No Exceeds the Int32 maximum

Use Int32 in your model

Select Int32 as the type of a class attribute when users and business logic work with whole numbers. For example, an OrderLine class can have a Quantity attribute of type Int32, with values such as 1, 5, or 0.

Choose a numeric type that supports fractional values when you must store values such as 1.5. For attributes whose database definition requires precision, scale, or length settings, see Documentation:Precision.

Use Int32 in OCL

In OCL, Int32 values can be used in expressions that require whole numbers. For example, Int32.Random(100) returns a random integer from 0 through 99; 100 is not included. See the random operator for the operator definition and a complete example.

When working with a remainder after division, use the OCL operation described in Modulus math.

Limits and conversion considerations

An Int32 cannot represent a fractional value or a whole number outside its minimum and maximum range. Check input values and conversion results when data can exceed these limits. For example, do not use an Int32 attribute for a value that may grow beyond 2,147,483,647.

See also

[[Category:Attributes and data types [Beginner]]]