The java.math.BigDecimal.precision() method returns the precision of this BigDecimal. The precision refers to the number of digits in the unscaled value.
public int precision()
Parameters: This method does not accept any parameters.
Return Value: This method returns an integer which denotes the precision of this BigDecimal object.
Input : 198.176 Output : 6 Input : 721111.111 Output : 9
Below programs illustrate the java.math.BigDecimal.precision() function in Java:
The precision of 198.176 is 6 The precision of 721111.111 is 9
The precision of 0.3 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.