FloatToInteger (open)

Converts a FLOAT value to an INTEGER value.

Syntax

LOADLIB "wh::float.whlib";

INTEGER FUNCTION FloatToInteger(FLOAT value)

Parameters

FLOAT value

The FLOAT value to be converted

Return value

INTEGER

The INTEGER value of @italic value

Description

This function can be used to convert a FLOAT to a INTEGER value. Make sure that the FLOAT value is in the INTEGER range to avoid an overflow. The INTEGER type does not support decimals, thus the FLOAT value will be truncated.

Examples

// The INTEGER value will be 17
INTEGER i := FloatToInteger(17.0);

// The INTEGER value will be 17. As an INTEGER doesn't support
// decimals, the decimals in the FLOAT value are lost.
INTEGER i := FloatToInteger(17.5);

// The INTEGER value will be -2147483648. Because the FLOAT value
// is outside of the INTEGER range, the INTEGER value will flow over.
INTEGER i := FloatToInteger(2147483648.);