Returns the integer portion of a number. The returned value has the same data type as the argument.
Int([num]) Fix([num]) |
The optional num argument is a Double or any valid numeric expression. If this argument is omitted, is a non-initialized variable, or Null, the function returns 0.
Both Int and Fix remove the fractional part of number and return the resulting integer value.
The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number, whereas Fix returns the first negative integer greater than or equal to number. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(num) is equivalent to:
Sgn(num) * Int(Abs(num))
This example illustrates how the Int and Fix functions return integer portions of numbers. In the case of a negative num argument, the Int function returns the first negative integer less than or equal to the num; the Fix function returns the first negative integer greater than or equal to the num.
Dim MyNumber MyNumber = Int(99.8) ' Returns 99. MyNumber = Fix(99.2) ' Returns 99. MyNumber = Int(-99.8) ' Returns -100. MyNumber = Fix(-99.8) ' Returns -99. MyNumber = Int(-99.2) ' Returns -100. MyNumber = Fix(-99.2) ' Returns -99. |
See Also |
Round Function, Type Conversion Functions |