• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Trouble with double primitive type

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a double value that can get very large, and when it goes over 10 million, java starts storing it in scientific notation.

So if double = 9999999.00, it look to me in the debugger as 9999999.00

But when the double over 10000000.00 it looks like 1.00E7.

It is messing up my report formating. How can I get the number to not convert to scientific notation?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Typically, all double no matter their size are *stored* in scientific notation (okay, actually it's a variation that is given by some IEEE standard). I suspect you are worried more about how the double is *displayed* instead. You should be able to get some control over this by using NumberFormat. Take a look at the API docs (follow the link) for more information.

HTH

Layne
[ October 06, 2004: Message edited by: Layne Lund ]
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anoter option is to turn your double into a BigDecimal. For example
this will print the following:
This is a double :1.0E8
This is a BigDecimal :100000000
 
M Burke
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that worked great, thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic