当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Java Math getExponent()用法及代码示例

Java Math getExponent() 方法从指定数字的浮点表示返回无偏 index 。

也就是说,将浮点数或双精度数转换为浮点表示。从表示中,该方法返回 index 部分。

用法:

Math.getExponent(value)

注意: 这getExponent()方法是静态方法。因此,我们可以直接使用类名调用该方法Math.

参数:

  • value- 要返回其 index 的数字

注意: 值可以是float或者double.

getExponent() 返回值

  • 从浮点表示返回无偏 index 价值

示例:Java 数学。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

  }
}

相关用法


注:本文由纯净天空筛选整理自 Java Math getExponent()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。