.scalb()

The Math.scalb() method returns the first argument multiplied by 2 to the power of the second argument.

Syntax

Math.scalb(value, scale)

The parameter value is of type double and the parameter scale is of type int.

Example

// Main.java
public class Main {
public static void main(String[] args) {
double value = 23.2;
int scale = 4;
int scale2 = 7;
System.out.println(Math.scalb(value, scale));
System.out.println(Math.scalb(value, scale2));
}
}

This will produce the following output:

371.2
2969.6

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn Java on Codecademy