Floating Constants
A floating constant is represented as a sequence of decimal digits with one decimal point, or an exponent notation. Some examples are:
41.9 5.67E-3 // The number 5.67*10-3
E can also be written as e. The
letter P or p is used to
represent a floating constant with an exponent to base 2 (ANSI C99);
for example:
2.7P+6 // The number 2.7*26
The decimal point or the notation of an exponent using
E, e,
P
(*), or
p
(*) is necessary to
distinguish a floating constant from an integer constant.
Unless otherwise specified, a floating constant has type
double. The suffix F or
f assigns the constant the type
float; the suffix L or
l assigns it the type long
double. Thus the constants in the previous examples have
type double, 12.34F has type
float, and 12.34L has type
long double.
Each of the following constants has type double.
All the constants in each row represent the same value:
5.19 |
0.519E1 |
0.0519e+2 |
519E-2 |
12. |
12.0 |
.12E2 |
12e0 |
370000.0 |
37e+4 |
3.7E+5 |
0.37e6 |
0.000004 |
4E-6 |
0.4e-5 |
.4E-5 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access