HTBasic Help
×
Menu
Index

INT

Performs the greatest integer function.
 
 INT( numeric-expression )
 
Usage:
J4=INT(2.7)
K=INT(-2.7)
Gif=INT(Number)
PRINT "Greatest Integer Function =";INT(Y)
 
Example:          INT.BAS
 
Description:
INT obtains the greatest integer that is less than or equal to the value of its argument. For positive numbers the effect is to truncate the fractional part (if any). For negative numbers, the result is different than you might first expect. For example, the INT of 4.9 is 4, but the INT of -4.9 is -5 since negative 5 is the largest integer less than negative 4.9.
 
Notice the differences among CINT, FIX and INT. CINT converts a REAL value to an INTEGER value by substituting the closest INTEGER to the value. FIX returns the closest integral value between the REAL value and zero. INT returns the closest integral value between the REAL value and negative infinity. Also, CINT actually changes the type from REAL to INTEGER while INT and FIX return integral results without changing the type. The following table helps illustrate these differences:
 
Value x
CINT(x)
FIX(x)
INT(x)
2.6
3
2.0
2.0
2.2
2
2.0
2.0
-2.2
-2
-2.0
-3.0
-2.6
-3
-2.0
-3.0
 
See Also: