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
numberis removed and the resulting integer value returned.Intdoesn’t roundnumberto the nearest whole number; for example,Int(100.9)returns 100.If
numberis negative,Intreturns the first negative integer less than or equal tonumber; for example,Int(-10.1)returns -11.
Programming Tips & Gotchas
IntandFixwork identically with positive numbers. However, for negative numbers,Fixreturns the first negative integer greater thannumber. For example,Int(-10.1)returns -10.Don’t confuse the
Intfunction withCInt.CIntcasts the number passed to it as anIntegerdatatype, whereasIntreturns the same datatype that was passed to it.
See Also
| Fix Function |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access