Home >>Java Math Methods >Java Math.getExponent() method

Java Math.getExponent() method

Java Math.getExponent() method

The Math.getExponent() Method is used to returns the unbiased exponent that was used in double or float representation.

Syntax

public static int getExponent(float x)  
public static int getExponent(double x)  

Parameters

x = This parameter is used for a value

Returns

It is used to returns the unbiased exponent of the argument.

  1. This method returns the unbiased exponent if the statement is positive or negative double or float value.
  2. This method will return Float. MAX EXPONENT + 1 or Double. MAX EXPONENT + 1 if the statement is -1 or Infinity.
  3. If Zero is the statement this method returns Float. MIN EXPONENT-1 or Double. MIN EXPONENT-1.

Java Math.getExponent() Method Example 1


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        double x = 35.12;  
        System.out.println(Math.getExponent(x));  
    }  
}  

Output:
5

Java Math.getExponent() Method Example 2


public class MyClass  
{  
    public static void main(String[] args)   
    {  
        float x = 14.5f;  
        System.out.println(Math.getExponent(x));  
    }  
}  

Output:
3

No Sidebar ads