A floating-point constant consists of:
Negative floating constants are taken as positive constants with the unary operator minus (-) prefixed.
Here are some examples:
Constant |
Value |
23.45e6 |
23.45 ( 10^6 |
.0 |
0 |
0. |
0.0 |
1. |
1.0 |
-1.23 |
-1.23 |
2e-5 |
2.0 ( 10^-5 |
3E+10 |
3.0 ( 10^10 |
.09E34 |
0.09 ( 10^34 |
In the absence of any suffixes, floating-point constants are of type double. However, you can coerce a floating constant to be of type float by adding an f or F suffix to the constant. Similarly, the suffix l or L forces the constant to be data type long double. The table below shows the ranges available for float, double, and long double.
Floating-point constant sizes and ranges
Type |
Size (bits) |
Range |
float |
32 |
3.4 ( 10^-38 to 3.4 ( 10^38 |
double |
64 |
1.7 ( 10^-308 to 1.7 ( 10^308 |
long double |
80 |
3.4 ( 10^-4932 to 1.1 ( 10^4932 |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|