6.3.1.4 Real floating and integer

Previous Table of Contents "New C Standard" commentary

686 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).

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

688 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.

689 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.

690 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.

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

692 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.

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

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

Next

Created at: 2008-01-30 02:39:41 The text from WG14/N1256 is copyright © ISO