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:
xxxxxxxxxx
1
package example;
2
3
public class Program {
4
5
public static void main(String[] args) {
6
7
System.out.println(-Float.MAX_VALUE); // -3.4028235e+38f or in hex: -0x1.fffffeP+127f
8
}
9
}
Output:
xxxxxxxxxx
1
-3.4028235e+38f
Warning: do not confuse
Float.MIN_VALUE
with float minimal value - it returns min positive float value.
Sometimes it is necessary to know minimal positive float value. To get its we can use Float.MIN_VALUE
.
xxxxxxxxxx
1
package example;
2
3
public class Program {
4
5
public static void main(String[] args) {
6
7
// Min positive float value:
8
//
9
System.out.println(Float.MIN_VALUE); // 1.4e-45f or in hex: 0x0.000002P-126f
10
}
11
}
Output:
xxxxxxxxxx
1
1.4e-45f