trunc

Typefunction
DictionaryLCS
LibraryLiveCode Script
Syntax
the trunc of <number>
trunc(<number>)
Summary

Returns the integer part of a number.

Introduced1.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
number

Any number, or expression that evaluates to a number.

Example
trunc(33.567) -- returns 33
trunc(-6.3) -- returns -6
Values
NameTypeDescription
return

The trunc function returns an integer.

RelatedKeyword: integer
Constant: return
Function: abs, round
Control Structure: function
Glossary: return
Description

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

Tagsmath