aspose file tools
The moose likes Beginning Java and the fly likes Math computations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Math computations" Watch "Math computations" New topic

Math computations

Aaron Webb

Joined: Aug 16, 2001
Posts: 17
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.
Peter Tran

Joined: Jan 02, 2001
Posts: 783
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!!!
Aaron Webb

Joined: Aug 16, 2001
Posts: 17
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.
I agree. Here's the link:
subject: Math computations