to

Converts a floating point number to an integral type.

Parameters

From

Source type.

To

Target type.

from From

Source value.

Return Value

Type: To

Truncated from (everything after the decimal point is dropped).

Throws

$(D_PSYMBOL ConvException) if from < To.min || from > To.max.

Examples

assert(1.5.to!int == 1);
assert(2147483646.5.to!int == 2147483646);
assert((-2147483647.5).to!int == -2147483647);
assert(2147483646.5.to!uint == 2147483646);

Meta