
The scalb(double a, int scale ) is an inbuilt method of Math class in Java which is used to get the value a x 2^scale . The result is accurately calculated when the exponent of the result is between Double.MIN_EXPONENT and Double.MAX_EXPONENT. It gives rise to four special results:
 It returns an infinity when the exponent of the result is larger than Double.MAX_EXPONENT.
 The result is NaN when the first argument is NaN.
 The result is an infinity of the same sign when the first argument is infinite.
 It returns a Zero of the same sign when the first argument is zero.
Syntax :
public static double scalb(double a, int scale)
Parameters : This method accepts two parameters they are:
 a: This is of the double type which is the number to be scaled by a power of two.
 scale: This is of integer type which is the power of 2 ,used to scale a
Return Value : The method returns a x 2^scale
Examples :Input: a = 77.23 scale = 3 Output = 617.84
Below program illustrates the java.lang.Math.scalb(double a, int scale) method:
// Java praogram to illustrate the
// java.lang.Math.scalb(double a, int scale )
import
java.lang.*;
public
class
Geeks {
public
static
void
main(String[] args)
{
double
p =
52.12
;
int
scale =
8
;
// It returns p x 2^scale
System.out.print(
"Value of Math.scalb("
+ p +
", "
+ scale +
") = "
);
System.out.println(Math.scalb(p, scale));
}
}
chevron_rightfilter_noneOutput:Value of Math.scalb(52.12, 8) = 13342.72

The java.lang.Math.scalb(float a, int scale ) is an inbuilt method which returns a x 2^scale . The result is accurately calculated when the exponent of the result is between Float.EXPONENT and Float.MAX_EXPONENT.
 It returns an infinity when the exponent of the result is larger than Float.MAX_EXPONENT.
 The result is NaN when the first argument is NaN.
 The result is an infinity of the same sign when the first argument is infinite.
 It returns a Zero of the same sign when the first argument is zero.
Syntax :
public static double scalb(float a, int scale)
Parameters : This method accepts two parameters:
 a: This is of float type which is the number to be scaled by a power of two.
 scale: This is of integer type which refers to the power of 2 used in scaling of a
Return Value : The method returns a x 2^scale
Examples :Input: a = 32.14f scale = 6 Output = 2056.96
Below program illustrates the java.lang.Math.scalb(float a, int scale ) method:
Program 1:// Java praogram to illustrate the
// java.lang.Math.scalb(float a, int scale )
import
java.lang.*;
public
class
Geeks {
public
static
void
main(String[] args)
{
float
p =
81
.27f;
int
scale =
8
;
// Calculate p multiplied by 2 raised in scale
System.out.print(
"Value of Math.scalb("
+
p +
", "
+ scale +
") = "
);
System.out.println(Math.scalb(p, scale));
}
}
chevron_rightfilter_noneOutput:Value of Math.scalb(81.27, 8) = 20805.12
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a studentfriendly price and become industry ready.
Recommended Posts:
 StrictMath scalb() Method in Java
 Java.math.BigInteger.modInverse() method in Java
 Java.math.BigInteger.probablePrime() method in Java
 Java.lang.Math Class in Java  Set 1
 Java.lang.Math Class in Java  Set 2
 java.lang.Math.atan2() in Java
 Java Math random() method with Examples
 Java Math asin() method with Example
 Java Math min() method with Examples
 Java Math max() method with Examples
 Math floorDiv() method in Java
 Java Math log() method with example
 Java Math abs() method with Examples
 Java Math acos() method with Examples
 Java Math hypot() method with Example
 Java Math exp() method with Example
 Java Math sin() method with Examples
 Java Math sinh() method with Examples
 Java Math cosh() method with Examples
 Java Math tanh() method with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.