Name
Int Function
Syntax
Int(number
)
-
number
Use: Required
Data Subtype: Any valid numeric datatype
The number to be truncated.
Return Value
Returns a value of the numeric data subtype passed to it.
Description
Returns the integer portion of a number.
Rules at a Glance
The fractional part of
number
is removed and the resulting integer value returned.Int
doesn’t roundnumber
to the nearest whole number; for example,Int(100.9)
returns 100.If
number
is negative,Int
returns the first negative integer less than or equal tonumber
; for example,Int(-10.1)
returns -11.
Programming Tips & Gotchas
Int
andFix
work identically with positive numbers. However, for negative numbers,Fix
returns the first negative integer greater thannumber
. For example,Int(-10.1)
returns -10.Don’t confuse the
Int
function withCInt
.CInt
casts the number passed to it as anInteger
datatype, whereasInt
returns the same datatype that was passed to it.
See Also
Fix Function |
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.