trunc

Converts a floating point value to an integer.

This function requires the SSE2 instruction set and it can't be inlined.

extern (C)
int
trunc
@trusted pure nothrow
(
T
)
()

Parameters

value
Type: T

Either a float or a double.

Return Value

Type: int

An integral value equal to the value nearest integral toward 0.

Examples

assert(trunc(0.2f) == 0);
assert(trunc(0.8f) == 0);
assert(trunc(-0.2f) == 0);
assert(trunc(-8.8f) == -8);

Meta