A floating-point literal consists of the following:
Both the integral and fractional parts are made up of decimal digits. You can omit either the integral part or the fractional part, but not both. You can omit either the decimal point or the exponent part, but not both.
.-----------. .-------. V | V | >>-+---+-------+-+--.----digit-+--+--------------+-+--+---+---->< | '-digit-' '-| exponent |-' | +-f-+ | .-------. | +-F-+ | V | | +-l-+ +---digit-+--.--+--------------+----------------+ '-L-' | '-| exponent |-' | | .-------. | | V | | '---digit-+--| exponent |-----------------------' Exponent: .-------. V | |--+-e-+--+----+----digit-+-------------------------------------| '-E-' +-+--+ '- --'
The magnitude range of float is approximately 1.2e-38 to 3.4e38. The magnitude range of double or long double is approximately 2.2e-308 to 1.8e308. If a floating-point constant is too large or too small, the result is undefined by the language.
The suffix f or F indicates a type of float, and the suffix l or L indicates a type of long double. If a suffix is not specified, the floating-point constant has a type double.
A plus (+) or minus (-) symbol can precede a floating-point literal. However, it is not part of the literal; it is interpreted as a unary operator.
The following are examples of floating-point literals:
Floating-Point Constant | Value |
---|---|
5.3876e4 | 53,876 |
4e-11 | 0.00000000004 |
1e+5 | 100000 |
7.321E-3 | 0.007321 |
3.2E+4 | 32000 |
0.5e-6 | 0.0000005 |
0.45 | 0.45 |
6.e10 | 60000000000 |
When you use the printf function to display a floating-point
constant value, make certain that the printf conversion code
modifiers that you specify are large enough for the floating-point constant
value.
Related References
A packed decimal literal is a kind of floating-point literal that
provides the ability to accurately represent large numeric quantities.
It can consist of an integral part, a decimal point, a fractional part, and
the mandatory suffix D. A packed decimal literal can have up
to sixty-three significant digits, including integral and fractional
parts.
A packed decimal literal is of the form:
.-----------. .-------. V | V | >>-----+-------+-+--.----digit-+----+-d-+---------------------->< '-digit-' '-D-'
Both the integral and fractional parts are made up of decimal digits. You can omit either the intergral part or the fractional part, but not both.
Related References
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.