StrictMath.scalb(float, int): This method is available in java.lang.StrictMath class of Java.
Syntax:
float java.lang.StrictMath.scalb(float f, int scaleFactor)
This method takes two arguments one of type float and another of type int as its parameters. This method returns f ×2^scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the float 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.
f: number to be scaled by a power of two.
scaleFactor: the power of 2 used to scale f.
Returns: f × 2^scaleFactor.
Exceptions: NA
Approach
Java
public class StrictMathscalbfloat {public static void main(String[] args) {float f = 1991.67f;int scaleFactor = 19;System.out.println(StrictMath.scalb(f, scaleFactor));}}
Output:
1.0442087E9
No comments:
Post a Comment