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