Java Math scalb() Method

The scalb() method of Java Math class returns a single perfectly rounded product of floating-point and member of the double value set as if performed by d*2scaleFacor  rounded value.

Syntax:

  1. public static double scalb(double d, int scaleFactor)
  2. public static float scalb(float d,int scaleFactor)

Parameters:

The parameter ‘d’ represents the number to be scaled by a power of 2 and ‘scaleFactor’ represents power of 2 used to scale d.

Return Value:

The scalb() method computes the rounded value for d*2scaleFacor.

Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Example 5:

Output: