Java.lang Package Classes

Java StrictMath - getExponent() Method



The java.lang.StrictMath.getExponent() method returns the unbiased exponent used in the representation of argument. In special cases it returns the following:

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

Syntax

public static int getExponent(double d)

Parameters

d Specify a double value.

Return Value

Returns the unbiased exponent used in the representation of argument.

Exception

NA.

Example:

In the example below, getExponent() method returns the unbiased exponent used in the representation of argument.

import java.lang.*;

public class MyClass {
 public static void main(String[] args) {
  System.out.println(StrictMath.getExponent(10.5)); 
  System.out.println(StrictMath.getExponent(25.0)); 
  System.out.println(StrictMath.getExponent(600.78)); 
  System.out.println(StrictMath.getExponent(1050.0));     
 }
}

The output of the above code will be:

3
4
9
10

❮ Java.lang - StrictMath