Floating-Point Literals

Floating-point numbers can be represented in a number of ways. The following are all legitimate floating-point numbers:

1003.45 .00100345e6 100.345E+1100345e–2
1.00345e3 0.00100345e+6  

Floating-point literals have several parts, which appear in the following order as shown in Table 3.9.

Table 3.9. Floating-Point Literal Requirements
PartIs It Required?Examples
Whole Number Not if fractional part is present. 0, 1, 100, 1003
Decimal Point Not if exponent is present; must be there if there is a fractional part.  
Fractional Cannot be present if there is no decimal point; must be there if there is no whole number part. 0, 1, 1415927
Exponent Only if there is no decimal point. e23, E–19, E6, e+307, e–1
Type Suffix No. The number ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.