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 negation of the scale.
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.
public int scale()
Parameters: This method does not accepts any parameter.
Return value: This method returns the scale of this BigDecimal object.
Below program illustrates the working of the above mentioned method:
The scale of 456.0 is 1 The scale of -1.456 is 3
The scale of 745 is 0 The scale of -174 is 0