Math scalb() Method in Java Last Updated : 30 Jul, 2018 Comments Improve Suggest changes Like Article Like Report The scalb(double a, int scale ) is an inbuilt method of Math class in Java which is used to get the value a x 2^scale . The result is accurately calculated when the exponent of the result is between Double.MIN_EXPONENT and Double.MAX_EXPONENT. It gives rise to four special results: It returns an infinity when the exponent of the result is larger than Double.MAX_EXPONENT. The result is NaN when the first argument is NaN. The result is an infinity of the same sign when the first argument is infinite. It returns a Zero of the same sign when the first argument is zero. Syntax : public static double scalb(double a, int scale) Parameters : This method accepts two parameters they are: a: This is of the double type which is the number to be scaled by a power of two. scale: This is of integer type which is the power of 2 ,used to scale a Return Value : The method returns a x 2^scale Examples : Input: a = 77.23 scale = 3 Output = 617.84 Below program illustrates the java.lang.Math.scalb(double a, int scale) method: java // Java praogram to illustrate the // java.lang.Math.scalb(double a, int scale ) import java.lang.*; public class Geeks { public static void main(String[] args) { double p = 52.12; int scale = 8; // It returns p x 2^scale System.out.print("Value of Math.scalb(" + p + ", " + scale + ") = "); System.out.println(Math.scalb(p, scale)); } } Output: Value of Math.scalb(52.12, 8) = 13342.72 The java.lang.Math.scalb(float a, int scale ) is an inbuilt method which returns a x 2^scale . The result is accurately calculated when the exponent of the result is between Float.EXPONENT and Float.MAX_EXPONENT. It returns an infinity when the exponent of the result is larger than Float.MAX_EXPONENT. The result is NaN when the first argument is NaN. The result is an infinity of the same sign when the first argument is infinite. It returns a Zero of the same sign when the first argument is zero. Syntax : public static double scalb(float a, int scale) Parameters : This method accepts two parameters: a: This is of float type which is the number to be scaled by a power of two. scale: This is of integer type which refers to the power of 2 used in scaling of a Return Value : The method returns a x 2^scale Examples : Input: a = 32.14f scale = 6 Output = 2056.96 Below program illustrates the java.lang.Math.scalb(float a, int scale ) method: Program 1: java // Java praogram to illustrate the // java.lang.Math.scalb(float a, int scale ) import java.lang.*; public class Geeks { public static void main(String[] args) { float p = 81.27f; int scale = 8; // Calculate p multiplied by 2 raised in scale System.out.print("Value of Math.scalb(" + p + ", " + scale + ") = "); System.out.println(Math.scalb(p, scale)); } } Output: Value of Math.scalb(81.27, 8) = 20805.12 Comment More infoAdvertise with us ankita_chowrasia Follow Improve Article Tags : Java Practice Tags : Java Similar Reads Math floorDiv() method in Java The Math.floorDiv() is a built-in math function in Java that returns the largest (closest to negative infinity) integer value that is less than or equal to the algebraic quotient of two numbers. As floorDiv() is static, object creation is not required. The floorDiv() method performs division that ro 3 min read Math floorMod() Method in Java The Math.floorMod() is a built-in math function in Java that returns the floor modulus of the integer arguments passed to it. Therefore, floor modulus is (a - (floorDiv(a, b) * b)), has the same sign as the divisor b, and is in the range of -abs(b) < result < +abs(b). The relationship between 3 min read StrictMath scalb() Method in Java The scalb(double num, int scale) is an inbuilt method of StrictMath class in Java which is used to calculate num * 2^scale and rounded as performed by a single correctly rounded floating point multiplied to a member of the double value argument. The result is calculated accurately when the exponent 3 min read Java Math subtractExact(int a , int b) method The subtractExact() is a built-in function in Java provided by the Math class. This method returns the difference of the arguments. It throws an exception if the result overflows an int or long data type. As subtractExact() is static, so object creation is not required.This method helps detect overf 2 min read Long signum() Method in Java The signum function also known as sign function is an odd mathematical function that extracts the sign of a real number. The java.lang.Long.signum() method is used to get the signum function of the specified long value. For a positive value, a negative value and zero, the method returns 1, -1 and 0 2 min read Math pow() Method in Java with Example The Math.pow() method in Java is used to calculate a number raised to the power of some other number. It is part of the java.lang.Math class and is widely used in mathematical computations, scientific calculations, and algorithmic problems. This function accepts two parameters and returns the value 3 min read java.math class and its methods | Set 1 Math class provides mathematical functions to perform basic numeric operations such as exponential, logarithm, square root, and trigonometric functions. cosh, sin, tan, abs, bitLength, multiply and many more. Implementations of the functions of Math class do not return bit-for-bit same results. Henc 4 min read Math fma() method in Java with Examples In Math class, there are two types of fma() method depending upon the parameters passed to it. The methods are: fma(double a, double b, double c): This method of Math class is used to return the exact product of the first two doubles with the addition of the third double and then round the result to 5 min read java.math class and its methods | Set 3 java.math class and its methods | Set 1 java.math class and its methods | Set 2 ceil() : java.math.ceil(double a) method returns the smallest possible value which is either greater or equal to the argument passed. The returned value is a mathematical integer.Special Case : Result is same, if the ret 5 min read StrictMath cbrt() Method in Java The java.lang.StrictMath.cbrt() is an inbuilt method in Java which is used to return the cube root of a given double value. The method shows three special results: The result is a zero with the same sign as the argument when the given argument is zero.The result is infinity with the same sign of arg 2 min read Like