Maximum value for Float in Java?

Jérôme Verstrynge picture Jérôme Verstrynge · Aug 16, 2011 · Viewed 89.4k times · Source

The following question indicates that the minimum value of a Double is -Double.MAX_VALUE. Is this also true for Float (i.e., -Float.MAX_VALUE)?

Answer

dlev picture dlev · Aug 16, 2011

Yes, -Float.MAX_VALUE is the negative number with largest magnitude. floats are represented the same way as doubles, just with half the storage space (and the accompanying loss of precision.) Since signs in IEEE 754 are represented by a single bit, flipping that bit doesn't change the overall magnitude attainable by the remaining bits.