• 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

Math computations

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could I get some thoughts on using the native datatypes vs. BigDecimal class for calculations as well as any other better alternatives than these two. My calculations involve large decimal numbers.
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaron,
Depending on what you mean by "large decimal numbers." If you require "arbitrary-precision", then the BigDecimal class is the way to go. There are other nice things about the BD class that you don't get with the primitive float/double type, but nothing is ever free. Using a class is going to cost you in performance. Unless you need the overhead, I recommend sticking with a primitive double which has The java.lang.Double.MAX_VALUE = 1.79769313486231570e+308!!!
-Peter
 
Aaron Webb
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I should add that I would be willing to sacrifice some performance for accuracy. The more accurate the better, but how much better is the accuracy between the two implementations.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic