6.4.4.2 Floating constants

Previous Table of Contents

836

floating-constant:
                decimal-floating-constant
                hexadecimal-floating-constant

decimal-floating-constant: fractional-constant exponent-partopt floating-suffixopt digit-sequence exponent-part floating-suffixopt

hexadecimal-floating-constant: hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part floating-suffixopt hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part floating-suffixopt

fractional-constant: digit-sequenceopt . digit-sequence digit-sequence .

exponent-part: e signopt digit-sequence E signopt digit-sequence

sign: one of + -

digit-sequence: digit digit-sequence digit

hexadecimal-fractional-constant: hexadecimal-digit-sequenceopt . hexadecimal-digit-sequence hexadecimal-digit-sequence .

binary-exponent-part: p signopt digit-sequence P signopt digit-sequence

hexadecimal-digit-sequence: hexadecimal-digit hexadecimal-digit-sequence hexadecimal-digit

floating-suffix: one of f l F L

837 A floating constant has a significand part that may be followed by an exponent part and a suffix that specifies its type.

838 The components of the significand part may include a digit sequence representing the whole-number part, followed by a period (.), followed by a digit sequence representing the fraction part.

839 The components of the exponent part are an e, E, p, or P followed by an exponent consisting of an optionally signed digit sequence.

840 Either the whole-number part or the fraction part has to be present;

841 for decimal floating constants, either the period or the exponent part has to be present.

842 The significand part is interpreted as a (decimal or hexadecimal) rational number;

843 the digit sequence in the exponent part is interpreted as a decimal integer.

844 For decimal floating constants, the exponent indicates the power of 10 by which the significand part is to be scaled.

845 For hexadecimal floating constants, the exponent indicates the power of 2 by which the significand part is to be scaled.

846 For decimal floating constants, and also for hexadecimal floating constants when FLT_RADIX is not a power of 2, the result is either the nearest representable value, or the larger or smaller representable value immediately adjacent to the nearest representable value, chosen in an implementation-defined manner.

847 For hexadecimal floating constants when FLT_RADIX is a power of 2, the result is correctly rounded.

848 An unsuffixed floating constant has type double.

849 If suffixed by the letter f or F, it has type float.

850 If suffixed by the letter l or L, it has type long double.

851 Floating constants are converted to internal format as if at translation-time.

852 The conversion of a floating constant shall not raise an exceptional condition or a floating-point exception at execution time.

853 The implementation should produce a diagnostic message if a hexadecimal constant cannot be represented exactly in its evaluation format;

854 the implementation should then proceed with the translation of the program.

855 The translation-time conversion of floating constants should match the execution-time conversion of character strings by library functions, such as strtod, given matching inputs suitable for both conversions, the same result format, and default execution-time rounding.64)

856 64) The specification for the library functions recommends more accurate conversion than required for floating constants (see 7.20.1.3).

Next

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