Skip to Main Content

New to Java

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!

Regarding Double Conversion & Decimal Precision

835783Feb 23 2011 — edited Apr 14 2011
Hi,

Here I'm converting a number into double & trying to use the precision upto 2 places
private String convertToDouble(String fieldValue)
   {
      double value = Double.parseDouble(fieldValue.replace(',', '.'));
      value = (double) Math.round(value * 100) / 100;
       return Double.toString(value);

    }
It's ok for short numbers e.g. 5555
But When I enter numbers like 9999999999 the output is
9.999999999E9

All I want is number should be converted in double then it should be precised upto 2 decimal places.
Please help.

Edited by: Mahi on Apr 14, 2011 3:43 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2011
Added on Feb 23 2011
13 comments
1,925 views