Int |
Math Functions | |
Aptilis 1 |
Int(x)
Int returns the integer part of a value.
Note that Int truncates the decimal part of a value,
which is slightly different from rounding. If you want
to round a value, you should add 0.5 to it if it's a positive
value or substract 0.5 from it if it's negative before using
Int. For example, taking the integer part of 3.1 and 3.9
gives 3 in both cases whereas 4 would have been much more
accurate in the second case.
You must then treat the integer number as a string,
because when Aptilis deals with numbers, they are
automatically stored as floating point values and
a string of zeroes might not be what you want, especially
if the value needs to be displayed.
Return value:
A string representing the integer part of x.
Example:
i = int(3.52) $ // The dollar is to avoid the '.0000' print(i$)Result:
3 |