Java Java API
Class:
java.lang.Math
Methods:
public static double scalb(double d,
int scaleFactor)
Returns d x 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.
public static float scalb(float f,
int scaleFactor)
Returns f x 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the float value set.
Examples
 package com.logicbig.example.math;
public class ScalbExample {
public static void main(String... args) { findScalb(35.97, 3); findScalb(71.14, 2); findScalb(-99.53, 5); findScalb(-0.14, 4); }
private static void findScalb(double d, int scaleFactor) { double result = Math.scalb(d, scaleFactor); System.out.printf("Math.scalb(%s,%s) = %s%n", d, scaleFactor, result); } }
OutputMath.scalb(35.97,3) = 287.76 Math.scalb(71.14,2) = 284.56 Math.scalb(-99.53,5) = -3184.96 Math.scalb(-0.14,4) = -2.24
 package com.logicbig.example.math;
public class ScalbExample2 {
public static void main(String... args) { findScalb(23.15f, 7); findScalb(99.25f, 5); findScalb(-78.12f, 3); findScalb(0.0f, 2); findScalb(-0f / 0, 11); }
private static void findScalb(float d, int scaleFactor) { float result = Math.scalb(d, scaleFactor); System.out.printf("Math.scalb(%s,%s) = %s%n", d, scaleFactor, result); } }
OutputMath.scalb(23.15,7) = 2963.2 Math.scalb(99.25,5) = 3176.0 Math.scalb(-78.12,3) = -624.96 Math.scalb(0.0,2) = 0.0 Math.scalb(NaN,11) = NaN
|
|