RAD Studio |  |

Floating Point Constants
See Also
Collapse All

A floating-point constant consists of:

- Decimal integer
- Decimal point
- Decimal fraction
- e or E and a signed integer exponent (optional)
- Type suffix: f or F or l or L (optional)

You can omit either the decimal integer or the decimal fraction (but not both). You can omit either the decimal point or the letter e (or E) and the signed integer exponent (but not both). These rules allow for conventional and scientific (exponent) notations.

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

See Also

Constants

Integer Constants

Integer Constant Without L Or U

Character Constants

The Three Char Types

Escape Sequences

Wide-character And Multi-character Constants

String Constants

Enumeration Constants

Constants And Internal Representation

Internal Representation Of Numerical Types

Constant Expressions

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!