Converts a floating point number to an integer value.
Syntax:RetDub = INT(Number) Return Value:Parameters:
|
👉 The INT function returns the integer portion of the floating point number as a double data type and not as an integer data type. This means that, for example, if the INT function is used directly as an integer parameter argument in another function, the INT function must be cast to an integer from its return double data type. An error will be thrown by the following example.
> DIM A% RANDOMIZE(TIMER) A% = IMOD(INT(RND * 1000000), 144) PRINT A%
However, casting the INT function return value from a double to an integer prevents the error as shown in the following example.
DIM A% RANDOMIZE(TIMER) A% = IMOD((INT)INT(RND * 1000000), 144) PRINT A%
DIM RetVal% RetVal% = FIX(0.4): PRINT " FIX(0.4) ",RetVal% RetVal% = FIX(0.6): PRINT " FIX(0.6) ",RetVal% RetVal% = FIX(-0.4): PRINT "FIX(-0.4) ",RetVal% RetVal% = FIX(-0.6): PRINT "FIX(-0.6) ",RetVal% RetVal% = FIX(1.4): PRINT " FIX(1.4) ",RetVal% RetVal% = FIX(1.6): PRINT " FIX(1.6) ",RetVal% RetVal% = FIX(-1.4): PRINT "FIX(-1.4) ",RetVal% RetVal% = FIX(-1.6): PRINT "FIX(-1.6) ",RetVal% PRINT " " RetVal% = INT(0.4): PRINT " INT(0.4) ",RetVal% RetVal% = INT(0.6): PRINT " INT(0.6) ",RetVal% RetVal% = INT(-0.4): PRINT "INT(-0.4) ",RetVal% RetVal% = INT(-0.6): PRINT "INT(-0.6) ",RetVal% RetVal% = INT(1.4): PRINT " INT(1.4) ",RetVal% RetVal% = INT(1.6): PRINT " INT(1.6) ",RetVal% RetVal% = INT(-1.4): PRINT "INT(-1.4) ",RetVal% RetVal% = INT(-1.6): PRINT "INT(-1.6) ",RetVal%
FIX(0.4) 0 FIX(0.6) 0 FIX(-0.4) 0 FIX(-0.6) 0 FIX(1.4) 1 FIX(1.6) 1 FIX(-1.4) -1 FIX(-1.6) -1 INT(0.4) 0 INT(0.6) 0 INT(-0.4) -1 INT(-0.6) -1 INT(1.4) 1 INT(1.6) 1 INT(-1.4) -2 INT(-1.6) -2