static int getExponent(float f)
描述 (Description)
java.lang.StrictMath.getExponent(float f)方法返回java.lang.StrictMath.getExponent(float f)表示中使用的无偏指数。它包括一些情况 -
- 如果参数为NaN或无穷大,则结果为Float.MAX_EXPONENT + 1。
- 如果参数为零或次正规,则结果为Float.MIN_EXPONENT -1。
声明 (Declaration)
以下是java.lang.StrictMath.getExponent()方法的声明
public static int getExponent(float f)
参数 (Parameters)
f - 这是浮点值。
返回值 (Return Value)
此方法返回浮点表示中使用的无偏指数。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.StrictMath.getExponent()方法的用法。
package com.iowiki;
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