0

I must be getting old:

On Oracle JDK 8:

class A {

   public static void main(String[] argv) {
      float f3 = Float.MIN_NORMAL;
      float f3e1 = f3/2.0f;
      System.out.println(f3 + " / 2 -> " + f3e1);
      float f3e2 = f3/4.0f;
      System.out.println(f3 + " / 4 -> " + f3e2);
   }
}

Result

1.17549435E-38 / 2 -> 5.877472E-39
1.17549435E-38 / 4 -> 2.938736E-39

How is that possible? Isn't the Float.MIN_NORMAL the smallest Float still different from 0.0 (a Float in Java being required to be 32-bit IEEE 754 floating point, sadly without exceptions (WTF!), and thus the normal is ~1.17549E−38)?

In which case, the printed values must be Double or something else with more precision than Float ... but the values are declared as float.

David Tonhofer
  • 14,559
  • 5
  • 55
  • 51

0 Answers0