目录

static int getExponent(double d)

描述 (Description)

java.lang.StrictMath.getExponent(double d)方法返回在double的表示中使用的无偏指数。 它包括一些案例 -

  • 如果参数为NaN或无穷大,则结果为Double.MAX_EXPONENT + 1。
  • 如果参数为零或次正规,则结果为Double.MIN_EXPONENT -1。

声明 (Declaration)

以下是java.lang.StrictMath.getExponent()方法的声明

public static int getExponent(double d)

参数 (Parameters)

d - 这是双值。

返回值 (Return Value)

此方法返回double表示中使用的无偏指数。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.StrictMath.getExponent()方法的用法。

package com.iowiki;
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);
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

Exponent value of 16.2 = 4.0
Exponent value of 512.3 = 9.0
↑回到顶部↑
WIKI教程 @2018