Error getting tags :
error 404Error getting tags :
error 404 trunc | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
trunc
Basics
Expander triangle
Type
Function
Syntax
the trunc of number trunc(number)
See Also
Introduced
1.0
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
None required
Summary
Returns the integer part of a number.
Examples

trunc(33.567) -- returns 33
trunc(-6.3) -- returns -6

Additional Comments
Expander triangle

Use the trunc function to round a number down.

Parameters:

The number is any number, or expression that evaluates to a number.

Value:

The trunc function returns an integer.

Comments:

The trunc function is different from round in that truncation completely ignores the fractional part of the number. For example, round(4.9) returns 5, but trunc(4.9) returns 4. This means that the trunc function does not always return the integer closest to the number.

User Comments
Expander triangle
User thumbnail
Craig Newman (dunbarx)
StarStarStarStarStar
Jan 22, 2010
Note that the trunc function will not return the integer portion of a number when the numberFormat property is in play:
set numberformat to "#.00" put 1 into y add 0 to y answer trunc(y) -- "1.00", not "1" as might be expected