BigDecimal signum() Method in Java Last Updated : 04 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.math.BigDecimal.signum() is an inbuilt method in Java that returns the signum function of this BigDecimal. The sign function or signum function is an odd mathematical function that extracts the sign of a real number. In mathematical expressions, the sign function is often represented as sgn. Syntax: public int signum() Parameters: This method does not accepts any parameter. Return value: This method can return three types of values: -1 if this BigDecimal < 0 0 if this BigDecimal = 0 1 if this BigDecimal is > 0 Below program illustrates the working of the above mentioned method: Program 1: Java // Program to demonstrate signum() method of BigDecimal import java.math.*; public class Gfg { public static void main(String[] args) { BigDecimal b1 = new BigDecimal("12743"); BigDecimal b2 = new BigDecimal("0"); BigDecimal b3 = new BigDecimal("-4512"); // Assigning the signum values of BigDecimal objects b1, b2, b3 // to int objects i1, i2, i3 respectively int i1 = b1.signum(); int i2 = b2.signum(); int i3 = b3.signum(); // Printing i1, i2, i3 values System.out.println("Signum function on " + b1 + " is " + i1); System.out.println("Signum function on " + b2 + " is " + i2); System.out.println("Signum function on " + b3 + " is " + i3); } } Output: Signum function on 12743 is 1 Signum function on 0 is 0 Signum function on -4512 is -1 Program 2: Java // Program to demonstrate signum() method of BigDecimal import java.math.*; public class Gfg { public static void main(String[] args) { BigDecimal b1 = new BigDecimal("17845452743"); BigDecimal b2 = new BigDecimal("000"); BigDecimal b3 = new BigDecimal("-444512"); // Assigning the signum values of BigDecimal objects b1, b2, b3 // to int objects i1, i2, i3 respectively int i1 = b1.signum(); int i2 = b2.signum(); int i3 = b3.signum(); // Printing i1, i2, i3 values System.out.println("Signum function on " + b1 + " is " + i1); System.out.println("Signum function on " + b2 + " is " + i2); System.out.println("Signum function on " + b3 + " is " + i3); } } Output: Signum function on 17845452743 is 1 Signum function on 0 is 0 Signum function on -444512 is -1 Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#signum() Comment More infoAdvertise with us Next Article BigDecimal signum() Method in Java T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-Functions java-math Java-BigDecimal Java-math-package +2 More Practice Tags : JavaMisc Similar Reads BigDecimal min() Method in Java The java.math.BigDecimal.min(BigDecimal val) method in Java is used to compare two BigDecimal values and return the minimum of the two. Syntax: public BigDecimal min(BigDecimal val) Parameters: The function accepts a BigDecimal object val as parameter whose value is compared with that of this BigDec 2 min read BigDecimal ulp() Method in Java The java.math.BigDecimal.ulp() is an inbuilt method in Java that returns the size of an ulp(unit in the last place) of this BigDecimal. An ulp of a nonzero BigDecimal value is defined as the positive distance between this value and the BigDecimal value next larger in magnitude with the same number o 2 min read BigDecimal plus() method in Java The java.math.BigDecimal.plus() is an inbuilt method in java that returns a BigDecimal whose value is (+this), and whose scale is this.scale(). This method, which simply returns this BigDecimal is included for symmetry with the unary minus method negate().Syntax: public BigDecimal plus()Parameters: 3 min read BigDecimal precision() Method in Java The java.math.BigDecimal.precision() method returns the precision of this BigDecimal. The precision refers to the number of digits in the unscaled value. Syntax: public int precision() Parameters: This method does not accept any parameters. Return Value: This method returns an integer which denotes 2 min read BigDecimal scale() Method in Java The java.math.BigDecimal.scale() is an inbuilt method in java that returns the scale of this BigDecimal. For zero or positive value, the scale is the number of digits to the right of the decimal point. For negative value, the unscaled value of the number is multiplied by ten to the power of the nega 2 min read Like