Skip to content
Related Articles

Related Articles

Improve Article

Java Math getExponent() method with Example

  • Last Updated : 09 Apr, 2018

The java.lang.Math.getExponent() is a built-in math function which returns the unbiased exponent used in the representation of a float.

  • If the argument is NaN or infinite, then the result is Float.MAX_EXPONENT + 1.
  • If the argument is zero or subnormal, then the result is Float.MIN_EXPONENT -1.


public static int getExponent(float val)
val - a float value

The method returns the unbiased exponent of the argument.

Example: To show working of java.lang.Math.getExponent() function

// Java program to demonstrate working
// of java.lang.Math.getExponent() method
import java.lang.Math;
class Gfg {
    // driver code
    public static void main(String args[])
        float x = 7689.1f;
        float y = -794.99f;
        // print the unbiased exponent of them
        // print the unbiased exponent of 0



Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :