B.17 Floating and Integral Conversions (§3.2.1.3)

When an integer is converted to a floating-point number that cannot be represented exactly, the result of the conversion is the nearest value that can be represented exactly. This result is the natural result of the conversion on the hardware, and can be higher or lower than the original value.

When a floating-point number is converted at compile time to an integer or another floating-point type, and the result cannot be represented, the compiler issues a diagnostic message.

When an integral number or double floating-point number is converted to a floating-point number that cannot exactly represent the original value, the result is rounded to the nearest value of type float . (For details, see the architecture manual for your platform; for example, the MIPS R-Series Processor Architecture Manual or the VAX Architecture Manual.)

When demoting a double value to float , if the value being converted is in the range of values that can be represented, but not represented exactly, the result is the nearest higher or lower value. DEC C rounds the result to the nearest representable float value.

Similar rounding is performed for demotions from long double to double or float .


Previous Page | Next Page | Table of Contents | Index