It's not a secret anymore!*
The moose likes Beginning Java and the fly likes What am i doing wrong ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What am i doing wrong ???" Watch "What am i doing wrong ???" New topic
Author

What am i doing wrong ???

anuj sahai
Greenhorn

Joined: Dec 02, 2000
Posts: 8
Hi,
I am facing a problem. Please let me know why this is happening and what is the solution to
I enter a value which is 9.99999999999999E14. This is equivalent to 999999999999999(15 9's). When i multiply this amount by 100 the value is changed to 9.9999999999999904E16. The value which i wanted to obtain after the multiplication was 99999999999999900 however it became 99999999999999904 probably cos the precision was lost.
Throughout the value is being assigned to a double
Please let me know how i can workaround this problem ?
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
Have a look at
java.math.BigDecimal and java.math.BigInteger.
W.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What am i doing wrong ???