Built-in functions: math_trunc()
The function math_trunc() rounds a float value by removing the fractional part.
Declaration
float math_trunc( float aValue )
Parameters
aValue
The value to round.
Discussion
The function math_trunc() returns the integer part of the value passed in the parameter aValue by removing the fractional digits. For example:
var float result1 = math_trunc( 11.3 ); // result1 = 11.0 var float result2 = math_trunc( -5.3 ); // result2 = -5.0 var float result3 = math_trunc( -7.7 ); // result3 = -7.0
See also the float instant property trunc as well as the cognate built-in functions math_floor(), math_ceil(), math_round() and math_fract().