Java Math scalb() 方法
示例
返回乘以 2 的冪的數字
System.out.println(Math.scalb(1.5, 4));
System.out.println(Math.scalb(1.0, 5));
System.out.println(Math.scalb(1.2, 0));
System.out.println(Math.scalb(1.85, 10));
自己動手試一試 »
定義和用法
scalb()
方法返回浮點數 x 和整數 y 的公式 x·2y 的結果。
語法
以下之一
public static double scalb(double x, int y)
public static float scalb(float x, int y)
引數值
引數 | 描述 |
---|---|
x | 必需。要乘以 2 的冪的數字。 |
y | 必需。基數 2 的指數。 |
技術詳情
返回 | 表示公式 x·2y 結果的 double 或 float 值。 |
---|---|
Java 版本 | 1.6+ |
❮ Math 方法