Java.lang.StrictMath.scalb() Method



The java.lang.StrictMath.scalb(double d, int scaleFactor) method returns d × 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.It include these cases:

  • If the first argument is NaN, NaN is returned. .
  • If the first argument is infinite, then an infinity of the same sign is returned.
  • If the first argument is zero, then a zero of the same sign is retrned.


Following is the declaration for java.lang.StrictMath.scalb() method

public static double scalb(double d, int scaleFactor)


  • d -- This is the number to be scaled by a power of two.

  • scaleFactor -- This is the power of 2 used to scale d.

Return Value

This method returns the d × 2scaleFactor


  • NA


The following example shows the usage of java.lang.StrictMath.scalb() method.

package com.tutorialspoint;

import java.lang.*;

public class StrictMathDemo {

   public static void main(String[] args) {
   double d1 = 3.8 , d2 = 4.9, d3 = 0.0;
   int power = 2;

   // returns (First argument*(pow(second argument,2) i.e d × 2scaleFactor 

   double scalbValue = StrictMath.scalb(d1, power); 
   System.out.println("value = " + scalbValue);
   scalbValue = StrictMath.scalb(d2, power); 
   System.out.println("value = " + scalbValue);
   scalbValue = StrictMath.scalb(d3, power); 
   System.out.println("value = " + scalbValue);

Let us compile and run the above program, this will produce the following result:

value = 15.2
value = 19.6
value = 0.0