Livecode Wiki
Advertisement

Returns the integer part of a number.

Built-in Function handler[]

Syntax:

trunc(<number>)

Examples:

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

Use the trunc function to round a number down.

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(constant) the integer closest to the number.

Parameters:

See also: abs (function),round (function),

Advertisement