将一个 float 或 double 数转换为浮点表示。从该表示中,该方法返回指数部分。
getExponent()
方法的语法是
Math.getExponent(value)
注意:getExponent()
方法是静态方法。因此,我们可以直接使用类名 Math
调用该方法。
getExponent() 参数
- value - 要返回其指数的数字
注意:value 可以是 float
或 double
。
getExponent() 返回值
- 返回 value 的浮点表示中的无偏指数
示例:Java Math.getExponent()
class Main {
public static void main(String[] args) {
// Math.getExponent() with float variable
float a = 50.8f;
System.out.println(Math.getExponent(a)); // 5
// Math.getExponent with double variable
double b = 89.3d;
System.out.println(Math.getExponent(b)); // 6
}
}
另请阅读