Java Math getExponent()

That is, a float or double number is converted into floating-point representation. From the representation, the method returns the exponent part.

The syntax of the getExponent() method is:

Math.getExponent(value)

Note: The getExponent() method is a static method. Hence, we can call the method directly using the class name Math.


getExponent() Parameters

  • value - number whose exponent is to be returned

Note: The value can be either float or double.


getExponent() Return Values

  • returns the unbiased exponent from the floating-point representation of value

Example: Java Math.getExponent()

class Main {
  public static void main(String[] args) {

    // Math.getExponent() with float variable
    float a = 50.8f;
    System.out.println(Math.getExponent(a));  // 5

    // Math.getExponent with double variable
    double b = 89.3d;
    System.out.println(Math.getExponent(b));  // 6

  }
}
Did you find this article helpful?