6.3.1.4 Real floating and integer

Previous Table of Contents

682 When a finite value of real floating type is converted to an integer type other than _Bool, the fractional part is discarded (i.e., the value is truncated toward zero).

683 If the value of the integral part cannot be represented by the integer type, the behavior is undefined.50)

684 When a value of integer type is converted to a real floating type, if the value being converted can be represented exactly in the new type, it is unchanged.

685 If the value being converted is in the range of values that can be represented but cannot be represented exactly, the result is either the nearest higher or nearest lower representable value, chosen in an implementation-defined manner.

686 48) The integer promotions are applied only: as part of the usual arithmetic conversions, to certain argument expressions, to the operands of the unary +, -, and ~ operators, and to both operands of the shift operators, as specified by their respective subclauses.

687 49) The rules describe arithmetic on the mathematical value, not the value of a given type of expression.

688 50) The remaindering operation performed when a value of integer type is converted to unsigned type need not be performed when a value of real floating type is converted to unsigned type.

689 Thus, the range of portable real floating values is (-1, Utype_MAX+1).

690 If the value being converted is outside the range of values that can be represented, the behavior is undefined.

Next

Created at: 2005-06-29 02:18:56 The text from WG14/N1124 is copyright © ISO