Java.lang.StrictMath.getExponent() 方法
描述
java.lang.StrictMath.getExponent(double d) 方法返回用于表示双精度的无偏指数。 它包括一些案例 −
- 如果参数为 NaN 或无穷大,则结果为 Double.MAX_EXPONENT + 1。
- 如果参数为零或次正规,则结果为 Double.MIN_EXPONENT -1。
声明
以下是 java.lang.StrictMath.getExponent() 方法的声明。
public static int getExponent(double d)
参数
d − 这是双精度值。
返回值
此方法返回用于表示双精度的无偏指数。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.getExponent() 方法的使用。
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);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Exponent value of 16.2 = 4.0 Exponent value of 512.3 = 9.0

