Why/when should I use BigDecimal instead of double for numerical calculations?

John Mitchell

Precision and accuracy. double uses a fixed-size data format so it can't always be precise or accurate in its representation of numbers. On the other hand, the BigDecimal class will use as much space as is necessary and uses computational algorithms that will be both precise and accurate for any number.

If you're dealing with any sort of numerical use where spot on precision and accuracy are critical then you really need to use BigDecimal rather than double.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact