Java .scalb()

Bobliuuu's avatar
Published Nov 28, 2022
Contribute to Docs

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.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

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

All contributors

Contribute to Docs

Learn Java on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours