Java Reference
In-Depth Information
f F d D
HexadecimalFloatingPointLiteral:
HexSignificand BinaryExponent FloatTypeSuffix
opt
HexSignificand:
HexNumeral
HexNumeral
.
0 x
HexDigits
opt
.
HexDigits
0 X
HexDigits
opt
.
HexDigits
BinaryExponent:
BinaryExponentIndicator SignedInteger
BinaryExponentIndicator:one of
p P
A floating-point literal is of type
float
if it is suffixed with an ASCII letter
F
or
f
; otherwise
The elements of the types
float
and
double
are those values that can be represented using the
IEEE 754 32-bit single-precision and 64-bit double-precision binary floating-point formats,
respectively.
The details of proper input conversion from a Unicode string representation of a
floating-point number to the internal IEEE 754 binary floating-point representation
are described for the methods
valueOf
of class
Float
and class
Double
of the package
java.lang
.
The largest positive finite literal of type
float
is
3.4028235e38f
.
The smallest positive finite non-zero literal of type
float
is
1.40e-45f
.
The largest positive finite literal of type
double
is
1.7976931348623157e308
. The smallest pos-
itive finite non-zero literal of type
double
is
4.9e-324
.
It is a compile-time error if a non-zero floating-point literal is too large, so that on rounded
conversion to its internal representation, it becomes an IEEE 754 infinity.
A program can represent infinities without producing a compile-time error by using con-
stant expressions such as
1f/0f
or
-1d/0d
or by using the predefined constants
POSITIVE_INFINITY
and
NEGATIVE_INFINITY
of the classes
Float
and
Double
.
It is a compile-time error if a non-zero floating-point literal is too small, so that, on rounded
conversion to its internal representation, it becomes a zero.