Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Java BigDecimal vs R vs Java Float, Double

I am working on a financial system where precision required is 6 decimal places only. We are currently using R but converting to Java. I had a debate with a colleague over whether we should go with BigDecimals or double / float primitive in Java. I was in favor of BigDecimal but his point was that R would be using primitives same as Java primitives so we would have already noticed if there were any issues with the precision. It should be noted that the end result we would convert to BigDecimal anyway this is just for the calculation itself. Who is correct here?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You should definitely use BigDecimal with DECIMAL 128. You should do this knowing that specifications may change in the future and more decimal points may be required. DECIMAL 128 is too too much solution, but it’s bullet proof.

Performance is important, but when it comes to money, accuracy is much much more important.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading