Java Math scalb() Method
Example
Return numbers multiplied by powers of 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));
Try it Yourself »
Definition and Usage
The scalb()
method returns the result of the formula x·2y for a floating point number x and an integer y.
Syntax
One of the following:
public static double scalb(double x, int y)
public static float scalb(float x, int y)
Parameter Values
Parameter | Description |
---|---|
x | Required. The number to be multiplied by the power of 2. |
y | Required. The exponent for the base 2. |
Technical Details
Returns: | A double or float value representing the result of the formula x·2y. |
---|---|
Java version: | 1.6+ |
❮ Math Methods