This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.

Iam taking a String from a file which is actuallya number with 18 decimals long and the Decimal format is rounding that in scientific notation to 8 decimals whereas i want the number in decimal notation . Plz help me over this

I am not absolutely sure what you want to do but I think you are running into problems that the double can not contain the information that you wish to store in it.

value 0.0000000000000 the outputis 0.0 value 0.000000165 the outputis 1.6E-7 value 0.00000000 the outputis 0.0 value 0.0000056789 the outputis 6.0E-6 value 0.00000545 the outputis 5.4E-6 value 0.123333547999 the outputis 0.12333355 value 123344534456550.12333 the outputis1.2334453445655012E14

What i need the number in Decimal not in scientific notation Plz help me over this if possible .i would be grateful to you for this

regards

vamsi

Vamsi,

I think you are trying to put to large number into a double. I think with the largest values we are loosing some precision. I'm not really sure what the largest values are that a double can contain. Maybe you should pose that question!

The scientific notation issue can be resolved using the decimalformat class.

Vamsi Chada
Greenhorn

Joined: Aug 12, 2004
Posts: 10

posted

0

Thanks for the help. But I still have a question here

I want to know when I insert a large decimal value , I mean with 20 places of precision into a double variable, How much precision is stored in the double variable.

Campbell gave you a link to the answer. But more fundamentally, there is no use for floating point if you need 20 digits of accuracy. Or none that mortals do, and the numerical analyst that do it for a living know lots more, and are still probably not using floats/doubles.

When you are calculating the gravitational pull of a comet on a planet, then its important, but for those calculations, you don't think about using doubles.

Vamsi Chada
Greenhorn

Joined: Aug 12, 2004
Posts: 10

posted

0

I had to sum up the percentage calls per customer which was taking atleast 20 places of decimal.
Some weird requirement but the big decimal has a performance issue but I had a work around solution of multiplying my double value with 10000000 and then use the round method.

Vamsi Chada wrote:I had a work around solution of multiplying my double value with 10000000 and then use the round method.
Thanks for all your answers and finally solved

I am surprised that your solution works. Its will not work in general. Be prepared to enter a QA/bug report on it when the real problem is discovered.