Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Double.parseDouble(String) : Problem to parse large String

807605Jul 5 2007 — edited Jul 16 2007
Hello,

I need to convert A String to a Double in my application without rounding of digits.
I have used the Double.parseDouble(String) method.

The maximum string length can be 17 including dot(.)
So if my String is (of length 17)
Eg.
S= �9999999999.999999� then I am getting the double value as
d= 9999999999.999998(compare the last digit)
If s = �9999999999.111111� then d = 9999999999.111110
If s = �9999999999.555555� then d = 9999999999.555555 (result that I want)
If s = �9999999999.666666� then d = 9999999999.666666 (result that I want)
If s = �9999999999.777777� then d = 9999999999.777777 (result that I want)
If s = �9999999999.888888� then d = 9999999999.888887
If s = �9999999999.999999� then d = 9999999999.999998
If s = �9123456789.123456� then d = 9123456789.123456

But string length up to 16 is giving me the accurate result
So any body can explain me that why it is happening? And how can i get the accurate result.
Thanks in advanced.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2007
Added on Jul 5 2007
10 comments
902 views