Maximum value for Float in Java?

前端 未结 5 617
一整个雨季
一整个雨季 2021-02-05 02:54

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)?

5条回答
  •  死守一世寂寞
    2021-02-05 03:34

    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.

提交回复
热议问题