Math scalb() Method in Java Last Updated : 30 Jul, 2018 Summarize Comments Improve Suggest changes Share 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 A 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 Like