2.0 3.0 > lang > int
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration
Documentation
 History

Int
`Value = Int ( Number )`

Returns the mathematical integer part of Number, i.e. the greatest integer which is less than Number.

### Example

PRINT Int(Pi)
PRINT Int(-Pi)

3
-4

 The behaviour of Int and Fix are the same for positive number, and are different for negative numbers.

' Example illustrate the use of Int function to truncate to whole number.

PRINT Int(3.2)
PRINT Int(3.9)
PRINT Int(6)
PRINT Int(-7.2)
PRINT Int(-7.9)

3
3
6
-8
-8

The Value is not limited to the Integer size (32 bits) nor to the Long size (64 bits). It may be Float.

PRINT Int(2e60), CInt(2e60)

2E+60 -2147483648

The next example shows how Int() works on a Boolean variable.

PRINT Int(TRUE)

True

The difference between Int() and CInt() is:

• Int() may return a Float value, CInt() is limited to 32 bit Integer.
• Int() rounds to the next lower value. i.e. -4.6 to -5, while CInt rounds toward 0 i.e. -4.6 to -4