# INT CINT FIX

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
CINT( number )
INT( number )
FIX( number)

Description:
CINT( number )
Round numbers with fractional portions up or down to the next whole number or integer.
Positive numbers ending in 0.5 are rounded up.
Negative numbers ending in 0.5 are rounded down (away from zero).

INT( number )
Truncate an expression to the next whole number less than or equal to the argument.

FIX( number)
Truncate a number to a whole number by eliminating the decimal point and all characters to the right of the decimal point.
The major difference between FIX and INT is that FIX provides a true integer function (ie, does not return the next lower number for negative numbers as INT() does).
This behaviour is for Microsoft compatibility.

Example:

PRINT "N",,"INT(N)",,"CINT(N)",,"FIX(N)"
FOR n = -2 TO 2 STEP 0.25
PRINT n,,INT(n),,CINT(n),,FIX(n)
NEXT n
N INT(N) CINT(N) FIX(N)
-2 -2 -2 -2
-1.75 -2 -2 -1
-1.5 -2 -2 -1
-1.25 -2 -1 -1
-1 -1 -1 -1
-0.75 -1 -1 0
-0.5 -1 -1 0
-0.25 -1 0 0
0 0 0 0
0.25 0 0 0
0.5 0 1 0
0.75 0 1 0
1 1 1 1
1.25 1 1 1
1.5 1 2 1
1.75 1 2 1
2 2 2 2

We can also convert to integers by assigning a float value to an integer:

DIM FLOAT n,k,s = 0.25
DIM INTEGER m
PRINT " N INT(N) CINT(N) FIX(N) n\1 k\2 m"
FOR n = -3 TO 3 STEP s
m = n ' asign a float to an integer
k = n * 2
PRINT STR$(n,2,2);TAB(8);INT(n);TAB(16);CINT(n);TAB(24);FIX(n);TAB(32);n\1;TAB(40);k\2;TAB(48);m
NEXT n
N INT(N) CINT(N) FIX(N) n\1 k\2 m
-3.00 -3 -3 -3 -3 -3 -3
-2.75 -3 -3 -2 -3 -3 -3
-2.50 -3 -3 -2 -3 -2 -3
-2.25 -3 -2 -2 -2 -2 -2
-2.00 -2 -2 -2 -2 -2 -2
-1.75 -2 -2 -1 -2 -2 -2
-1.50 -2 -2 -1 -2 -1 -2
-1.25 -2 -1 -1 -1 -1 -1
-1.00 -1 -1 -1 -1 -1 -1
-0.75 -1 -1 0 -1 -1 -1
-0.50 -1 -1 0 -1 0 -1
-0.25 -1 0 0 0 0 0
0.00 0 0 0 0 0 0
0.25 0 0 0 0 0 0
0.50 0 1 0 1 0 1
0.75 0 1 0 1 1 1
1.00 1 1 1 1 1 1
1.25 1 1 1 1 1 1
1.50 1 2 1 2 1 2
1.75 1 2 1 2 2 2
2.00 2 2 2 2 2 2
2.25 2 2 2 2 2 2
2.50 2 3 2 3 2 3
2.75 2 3 2 3 3 3
3.00 3 3 3 3 3 3

Last edited: 29 September, 2020