Languages
[Edit]
EN

Java - min float value

4 points
Created by:
Lia-Perez
415

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

 

See also

  1. Java - max float value

  2. Java - min double value

  3. Java - max double value

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂

Join