A floating literal consists of
an optional prefix specifying a base,
an integer part,
a radix point,
a fraction part,
an
e,
E,
p or
P,
an optionally signed integer exponent, and
an optional type suffix
. The integer and fraction parts both consist of
a sequence of decimal (base ten) digits if there is no prefix, or
hexadecimal (base sixteen) digits if the prefix is
0x or
0X. [
Example: The floating literals
1.602'176'565e-19 and
1.602176565e-19
have the same value
. —
end example ]
Either the integer part or the fraction part (not both) can be omitted
. Either the radix point or the letter
e or
E and
the exponent (not both) can be omitted from a decimal floating literal
. The radix point (but not the exponent) can be omitted
from a hexadecimal floating literal
. The integer part, the optional radix point, and the optional fraction part,
form the
significand of the floating literal
. In a decimal floating literal, the exponent, if present,
indicates the power of 10 by which the significand is to be scaled
. In a hexadecimal floating literal, the exponent
indicates the power of 2 by which the significand is to be scaled
. [
Example: The floating literals
49.625 and
0xC.68p+2 have the same value
. —
end example ]
If the scaled value is in
the range of representable values for its type, the result is the scaled
value if representable, else the larger or smaller representable value
nearest the scaled value, chosen in an
implementation-defined manner
. The type of a floating literal is
double
unless explicitly specified by a suffix
. The suffixes
f and
F specify
float,
the suffixes
l and
L specify
long
double. If the scaled value is not in the range of representable
values for its type, the program is ill-formed
.