By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

count the number of digits after the decimal point

P: 2
Hi
Can anyone tell me how to find the number of digits after the decimal point in a double data type.I dont want to convert the double data type in to string.

Thnaks in Advance

Ramya
Nov 10 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
What you are asking for is not possible. Even assuming that you have limited you double to a range that has decimal places (i.e. for values greater than 1e15 there are no places after the decimal) it is not possible to calculate it. This is because doubles do not hold an exact value they hold an approximation so you might think that the value of the double is

1.375

and has 3 decimal places, however it could be

1.37499999999999

or

1.37500000000001

and have 14 decimal places.


Also I do not see what use this piece of information would be (unless it is a coursework assignment of course, they are often pointless).
Nov 10 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.