EN
Java - min float value
4
points
In Java, min float number value can be achieved using -Float.MAX_VALUE
what is equal to -3.4028235e+38f
.
Practical example:
package example;
public class Program {
public static void main(String[] args) {
System.out.println(-Float.MAX_VALUE); // -3.4028235e+38f or in hex: -0x1.fffffeP+127f
}
}
Output:
-3.4028235e+38f
Warning: do not confuse
Float.MIN_VALUE
with float minimal value - it returns min positive float value.
Min positive float value
Sometimes it is necessary to know minimal positive float value. To get its we can use Float.MIN_VALUE
.
package example;
public class Program {
public static void main(String[] args) {
// Min positive float value:
//
System.out.println(Float.MIN_VALUE); // 1.4e-45f or in hex: 0x0.000002P-126f
}
}
Output:
1.4e-45f