round

Converts a floating point value to an integer.

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

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

Parameters

value
Type: T

Either a float or a double.

Return Value

Type: int

An integer equal to the nearest integral value.

Examples

assert(round(0.2f) == 0);
assert(round(0.8f) == 1);
assert(round(-0.2f) == 0);
assert(round(-0.8f) == -1);

Meta