truncate

Purpose

Discard the fractional part of a number.

Syntax

returnedNum = truncate(numFlt)

returnedNum - type: number
numFlt - type: float

Returns

The given number with its fractional part removed.

Remarks

Analogous to the trunc function in C/C++. Rounds toward zero, so truncate(-3.7) is -3, whereas floor(-3.7) is -4.

Example

@CODE
"output.txt" << truncate(3.7) << "\n";
@@CODE

Outputs:

3

See Also

Math Functions