Java.lang.StrictMath.getExponent() Method



Description

The java.lang.StrictMath.getExponent(double d) method returns the unbiased exponent used in the representation of a double. It include some cases −

  • 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.

Declaration

Following is the declaration for java.lang.StrictMath.getExponent() method

public static int getExponent(double d)

Parameters

d − This is the double value.

Return Value

This method returns the unbiased exponent used in the representation of a double.

Exception

NA

Example

The following example shows the usage of java.lang.StrictMath.getExponent() method.

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {

      double d1 = 16.2 , d2 = 512.3;
   
      // returns the unbiased exponent used in the representation of a double
      double exponentValue = StrictMath.getExponent(d1); 
      System.out.println("Exponent value of " + d1 + " = " + exponentValue);
        
      exponentValue = StrictMath.getExponent(d2); 
      System.out.println("Exponent value of " + d2 + " = " + exponentValue);
   }
}

Let us compile and run the above program, this will produce the following result −

Exponent value of 16.2 = 4.0
Exponent value of 512.3 = 9.0
java_lang_strictmath.htm
Advertisements