Java.lang.StrictMath 类

java.lang.StrictMath.getExponent() 方法返回参数表示中使用的无偏指数。在特殊情况下,它返回以下内容:

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

语法

public static int getExponent(double d)

参数

d 指定双精度值。

返回值

返回参数表示中使用的无偏指数。

例外

无。

示例:

在下面的示例中,getExponent() 方法返回表示中使用的无偏指数

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));     
 }
}

上述代码的输出将是:

3
4
9
10