BigDecimal signum() Method in Java
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.
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:
Signum function on 12743 is 1 Signum function on 0 is 0 Signum function on -4512 is -1
Signum function on 17845452743 is 1 Signum function on 0 is 0 Signum function on -444512 is -1
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.