HTBasic Help
×
Menu
Index

FIX

Truncates a value to INTEGER.
 
 FIX ( numeric-expression)
 
Usage:
DRAW FIX(X),Y
 
Example:           FIX.BAS
 
Description:
The effect of FIX is to remove the fractional part of its argument.
 
Notice the differences among FIX, CINT and INT. FIX returns the closest integral value between the REAL value and zero. CINT converts a REAL value to an INTEGER 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
 
BackPorting to HP BASIC:
FIX is a new HTBasic function that is not available in HP BASIC. It should not be used in programs that must be ported back to HP BASIC.
 
See Also: