Information Technology Reference
In-Depth Information
Real Literals
Literals for real numbers consist of the following:
Decimal dig ts
An optional decimal point
An optional exponent part
An optional suffix
For example, the following code shows various formats of literals of the real types:
float f1 = 236F;
double d1 = 236.714;
double d2 = .35192;
double d3 = 6.338e-26;
The valid formats for real literals are shown in Figure 8-2. Components with names in
square brackets are optional. The real suffixes and their meanings are shown in Table 8-2.
Figure 8-2.
The real literal formats
Table 8-2.
Suffixes for the Real Literals
Suffix
Real Type
double
None
F
,
f
float
D
,
d
double
M
,
m
decimal
■
Note
Real literals without a suffix are of type
double
, not
float
!