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 方法