HP C A.06.05 Reference Manual

Type Conversions
Arithmetic Conversions
Chapter 4 81
Floating Conversions
When an integer value is converted to a floating type, the result is the equivalent
floating-point value. If it cannot be represented exactly, the result is the nearest representable
value. If the two nearest representable values are equally near, the result is the one whose
least significant bit is zero.
When a long long is converted into a floating type, no overflow will occur but may result in
loss of precision. Converting a long long into a quad precision floating point value should be
precise with no overflow.
When a floating type is converted into a long long type, the fractional part is discarded and
overflow may occur.
When floating-point types are converted to integral types, the source type value must be in
the representable range of the destination type or the result is undefined. The result is the
whole number part of the floating-point value with the fractional part discarded as shown in
the following examples:
int i;
i = 9.99; /* i gets the value 9 */
i = -9.99; /* i gets the value -9 */
float x1 = 1e38; /* legal; double is converted to float */
float x2 = 1e39; /* illegal; value is outside of range
for float */
long double x3 = 1.f; /* legal; float is converted to long
double */
When a long double value is converted to a double or float value, or a double value is
converted to a float value, if the original value is within the range of values representable in
the new type, the result is the nearest representable value (if it cannot be represented
exactly). If the two nearest representable values are equally near, the result is the one whose
least significant bit is zero. When a float value is converted to a double or long double value, or
a double value is converted to a long double value, the value is unchanged.
Arrays, Pointers, and Functions
An expression that has function type is called a function designator. For example, a function
name is a function designator. With two exceptions, a function designator with type “function
returning type” is converted to an expression with type “pointer to function returning type.
The exceptions are when the function designator is the operand of sizeof (which is illegal) and
when it is the operand of the unary & operator.