• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bigdecimal and Double

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the advantage of using java.math.BigDecimal over java.lang.Double or what is the difference?
Thanks
Marilyn
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BigDecimal has no limitations on precision. This can be pretty important in financial applications, for example.
- Peter
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Difference is that you can store much larger numbers in BigDecimal.
Double has a maximum value of Double.MAX_VALUE = 1.7976931348623157 E308.
But BigDecimal can hold Decimal values that are HUGE. For example, I created a BigDecimal that is (Double.MAX_VALUE)^300!!! I'm not sure what the upper bound is ( if one exists).
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the sake of completeness:
1. A link to the documentation for BigDecimal
2. A link to the documentation for Double
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic