• Post Reply Bookmark Topic Watch Topic
  • New Topic

counting decimel positions in a double  RSS feed

 
Eric schaab
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know how to count decimel positions in a double

for example
1.22 =2 positions
1.4433 =4 positions

I want to use this to do some error checking. Meaning I want to check for 2 positions and if it is greater than 2 positions throw a message
 
Ankit Garg
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric, welcome to javaranch.

Well you can use the java.math.BigDecimal class to do your task. It has a scale method which returns the number of digits after the decimal...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!