Java.lang.StrictMath.getExponent() 方法
描述
java.lang.StrictMath.getExponent(float f) 方法返回用于表示浮点数的无偏指数。它包括一些情况 −
- 如果参数为 NaN 或无穷大,则结果为 Float.MAX_EXPONENT + 1。
- 如果参数为零或低于正常值,则结果为 Float.MIN_EXPONENT -1。
声明
以下是 java.lang.StrictMath.getExponent() 方法的声明。
public static int getExponent(float f)
参数
f − 这是浮点值。
返回值
此方法返回用于表示浮点数的无偏指数。
异常
NA
示例
下面的例子展示了 java.lang.StrictMath.getExponent() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class StrictMathDemo {
public static void main(String[] args) {
float f1 = 32 , f2 = 1024;
// returns the unbiased exponent used in the representation of a float
double exponentValue = StrictMath.getExponent(f1);
System.out.println("Exponent value of " + f1 + " = " + exponentValue);
exponentValue = StrictMath.getExponent(f2);
System.out.println("Exponent value of " + f2 + " = " + exponentValue);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Exponent value of 32.0 = 5.0 Exponent value of 1024.0 = 10.0

