How to use scalb(double d, int scaleFactor) to get the d × 2 power by scaleFactor in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        float f = 3.14f;
        int i = 2;
        
        // Math.scalb(float f,int scaleFactor)
        // (2 * 2) * 3.14 = 12.56
        System.out.println("Math.scalb(" + f + "," + i + ") = " + Math.scalb(f, i));

    }
}
 
/*
run:

Math.scalb(3.14,2)=12.56
 
*/

 



answered Sep 10, 2016 by avibootz
...