StrictMath.scalb(double, int) in Java

StrictMath.scalb(double, int): This method is available in java.lang.StrictMath class of Java.

Syntax:

double java.lang.StrictMath.scalb(double d, int scaleFactor)

This method takes two arguments one of type double and another of type int as its parameters. This method returns d ×2^scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.

Note:

1. If the first argument is NaN, NaN is returned.

2. If the first argument is infinite, then an infinity of the same sign is returned.

3. If the first argument is zero, then a zero of the same sign is returned.

Parameters: Two parameters are required for this method.

d: number to be scaled by a power of two.

scaleFactor: the power of 2 used to scale d.

Returns: d × 2^scaleFactor.

Exceptions: NA

Approach

Java

public class StrictMathscalbdouble {
    public static void main(String[] args) {

        double d = 18189.191;
        int scaleFactor = 12;
        System.out.println(StrictMath.scalb(d, scaleFactor));
    }
}

Output:

7.4502926336E7


StrictMath.scalb(float, int)


No comments:

Post a Comment