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

- 1
- 1

- 57,710
- 92
- 283
- 453
-
1Do you mean -Float.MAX_VALUE? – dckrooney Aug 15 '11 at 22:19
-
1Why wouldn't [this](http://download.oracle.com/javase/6/docs/api/java/lang/Float.html#MIN_VALUE) be true? – CoolBeans Aug 15 '11 at 22:20
-
1@CoolBeans read his linked question; he's talking about the "negative number with the largest magnitude". – dlev Aug 15 '11 at 22:21
-
1@dlev Yes, I am referring to "negative number with the largest magnitude" – Jérôme Verstrynge Aug 15 '11 at 22:26
5 Answers
Yes, -Float.MAX_VALUE
is the negative number with largest magnitude. float
s are represented the same way as double
s, 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.

- 48,024
- 5
- 125
- 132
Yes - it's the same bit pattern as Float.MAX_VALUE
except with the sign bit flipped... and that's another way to get at the value:
public class Test {
public static void main(String[] args) {
// Float.MAX_VALUE is intBitsToFloat(0x7f7fffff)
// so we set the most significant bit - the sign bit
float f = Float.intBitsToFloat((int) 0xff7fffff);
System.out.println(f == -Float.MAX_VALUE); // true
}
}

- 1,421,763
- 867
- 9,128
- 9,194
EDIT: My original answer appears to be badly incorrect. Thank you @aioobe for pointing this out.
Instead, using the magic of java code to answer the title question:
System.out.printf( "Float.MAX_VALUE: %,f\n", Float.MAX_VALUE );
Float.MAX_VALUE: 340,282,346,638,528,860,000,000,000,000,000,000,000.000000
System.out.printf("in scientific notation: %.18g\n", Float.MAX_VALUE );
in scientific notation: 3.40282346638528860e+38
System.out.printf(
"in hexadecimal floating-point number with a significand and "
+ "an exponent: %a", Float.MAX_VALUE );
in hexadecimal floating-point number with a significand and an exponent: 0x1.fffffep127

- 502
- 1
- 5
- 14
Yes, it's also true for Float.
For more information check the manual here http://download.oracle.com/javase/7/docs/api/java/lang/Float.html

- 30,033
- 48
- 152
- 225

- 44,836
- 10
- 105
- 121
Yes it is, and for exactly the same reason as stated in the answer for the question you linked, Floats and Doubles use IEEE754 representation which is "symmetrical" due to the way they are stored.

- 32,488
- 6
- 61
- 79