Updates:
Turns out that this is the expected behaviour from the java doc:
A constant holding the smallest positive nonzero value of type float, 2-149.
So now, how do I get the smallest negative value that a float can hold?
Just came across the most weirdest thing ever in Java – 0f > Float.MIN_VALUE returns false!
Similarly, anything less than 0, (say -10 for example) is surprisingly not greater than Float.MIN_VALUE.
However, 0 > Integer.MIN_VALUE returns true!
Want to try it out?
public class E { public static void main(String[] args) { System.out.println("1f > Float.MIN_VALUE: " + (1f > Float.MIN_VALUE)); System.out.println("0f > Float.MIN_VALUE: " + (0f > Float.MIN_VALUE)); System.out.println("-1f > Float.MIN_VALUE: " + (-1f > Float.MIN_VALUE)); System.out.println("0f < Float.MIN_VALUE: " + (0f < Float.MIN_VALUE)); System.out.println("0f == Float.MIN_VALUE: " + (0f == Float.MIN_VALUE)); } }
Result:
1f > Float.MIN_VALUE: true 0f > Float.MIN_VALUE: false -1f > Float.MIN_VALUE: false 0f < Float.MIN_VALUE: true 0f == Float.MIN_VALUE: false