# StrictMath scalb() Method in Java

- The
**scalb(**is an inbuilt method of StrictMath class in Java which is used to calculate*double num, int scale*)*num** 2^*scale*and rounded as performed by a single correctly rounded floating point multiplied to a member of the double value argument.- The result is calculated accurately when the exponent of the result is between
**Double.MIN_EXPONENT**and**Double.MAX_EXPONENT**. - An infinity is returned when the exponent of the result is greater than
**Double.MAX_EXPONENT**. - When the result is subnormal then the correctness may be lost which means when scalb(
*num, scale*) is subnormal, scalb(scalb(*num, scale*), -scale) may not equal*num*. - The result is NaN when the
*num*is NaN - The result is an infinity of the same sign of
*num*when*num*is infinite - The result will be a zero of the same sign when the
*num*is zero.

**Syntax:**public static double scalb(

*double num, int scale*)**Parameters:**The method accepts two parameter:*num*: This is of double type and refers to number to be scaled by a power of 2.*scalb*: This is of integer type and refers to the power of 2 used to scale*num*.

**Return Value :**The method returns the*num*× 2^*scale*.**Examples :**Input: num = 7 scalb = 2 Output: 28

Below program illustrate the java.lang.StrictMath.scalb() method.

`// Java praogram to illustrate the`

`// java.lang.StrictMath.scalb()`

`import`

`java.lang.*;`

`public`

`class`

`Geeks {`

`public`

`static`

`void`

`main(String[] args) {`

`double`

`num1 =`

`12`

`, num2 = -`

`7.2`

`, num3 =`

`0.0`

`;`

`int`

`scalb =`

`2`

`;`

`double`

`scalb_Value = StrictMath.scalb(num1, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`scalb_Value = StrictMath.scalb(num2, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`scalb_Value = StrictMath.scalb(num3, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`}`

`}`

*chevron_right**filter_none***Output:**Output = 48.0 Output = -28.8 Output = 0.0

- The result is calculated accurately when the exponent of the result is between
- The
**scalb(float num, int scale)**is the inbuilt method of StrictMath class in Java to calculate*num** 2^*scale*and rounded as performed by a single correctly rounded floating point multiplied to a member of the float value argument.- The result is calculated accurately when the exponent of the result is between
**Float.MIN_EXPONENT**and**Float.MAX_EXPONENT**. - An infinity is returned when the exponent of the result greater than
**Float.MAX_EXPONENT**. - When the result is subnormal then the correctness may be lost which means when scalb(
*num, scale*) is subnormal, scalb(scalb(*num, scale*), -scale) may not equal*num*. - The result is NaN when the
*num*is NaN - The result is an infinity of the same sign of
*num*when*num*is infinite - The result will be a zero of the same sign when the
*num*is zero.

**Syntax :**public static float scalb(

*float num, int scale*)**Parameters:**The method accepts two parameter:*num*: This is of float type and refers to number to be scaled by a power of 2.*scalb*: This is of integer type and refers to the power of 2 used to scale*num*.

**Return Value :**The method returns the*num*× 2^*scale*.**Examples :**Input: num = 2.5f scalb = 4 Output: 40.0

Below program illustrate the java.lang.StrictMath.scalb() method.

`// Java praogram to illustrate the`

`// java.lang.StrictMath.scalb()`

`import`

`java.lang.*;`

`public`

`class`

`Geeks {`

`public`

`static`

`void`

`main(String[] args) {`

`float`

`num1 =`

`8`

`.3f, num2 = -`

`4`

`.2f, num3 =`

`0`

`.0f;`

`int`

`scalb =`

`3`

`;`

`float`

`scalb_Value = StrictMath.scalb(num1, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`scalb_Value = StrictMath.scalb(num2, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`scalb_Value = StrictMath.scalb(num3, scalb);`

`System.out.println(`

`"Output = "`

`+scalb_Value);`

`}`

`}`

*chevron_right**filter_none***Output:**Output = 66.4 Output = -33.6 Output = 0.0

- The result is calculated accurately when the exponent of the result is between

## Recommended Posts:

- Math scalb() Method in Java
- StrictMath pow() Method in Java
- StrictMath tan() Method in Java
- StrictMath exp() Method in Java
- StrictMath sin() Method in Java
- StrictMath log() Method In Java
- StrictMath max() Method in Java With Examples
- StrictMath min() Method in Java with Examples
- StrictMath hypot() Method in Java
- StrictMath round() method in Java
- StrictMath IEEEremainder() Method in Java
- StrictMath floor() Method in Java
- StrictMath random() Method in Java
- StrictMath rint() Method in Java
- StrictMath multiplyExact() Method in Java

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.