Java: Range of a float
A float
is a 32-bit IEEE 754 floating point.
Min value (inclusive) and max value (inclusive):
−3.40282347×1038
⋯
3.40282347×1038
⋯
3.40282347×1038
or, equivalently
−1.111⋯1×2127 … 1.111⋯1×2127
The maximum value is available as a constant: Float.MAX_VALUE
.
The minimum value is -Float.MAX_VALUE
, and not Float.MIN_VALUE
. For details, see Why's Double.MIN_VALUE is positive? Integer.MIN_VALUE is negative!
The constant Float.MIN_VALUE
is the smallest value greater than 0, i.e. not the smallest possible value. (This constant corresponds to Epsilon
in .NET.) For details, see Float.MIN_VALUE vs Float.MIN_NORMAL
See ranges of all primitive types here: Ranges of Primitive Types