22.6 Floating Point
Implementation-Defined Behavior for Floating Point is covered in section G.3.6 of the ANSI C Standard.
Is the scaled value of a floating constant that is in the range of the representable value for its type, the nearest representable value, or the larger representable value immediately adjacent to the nearest representable value, or the smallest representable value immediately adjacent to the nearest representable value? (ISO 6.1.3.1)
The nearest representable value.
The following table describes the amount of storage and range of various types of floating point numbers: (ISO 6.1.2.5)
Designation | Size (bits) | Range |
---|---|---|
float |
32 | 1.175494e-38 … 3.40282346e+38 |
double* |
32 | 1.175494e-38 … 3.40282346e+38 |
long double |
64 | 2.22507385e-308 … 1.79769313e+308 |
* double is
equivalent to long double if
-fno-short-double is used. |
What is the direction of truncation, when an integral number is converted to a floating-point number, that cannot exactly represent the original value? (ISO 6.2.1.3)
Down.
What is the direction of truncation, or rounding, when a floating-point number is converted to a narrower floating-point number? (ISO 6.2.1.4)
Down.