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 valueOf not precise?

I am not sure if I am using this wrong but, if I do BigDecimal.valueOf(15350.00), why does it show as 15350.0 instead of 15350.00?

>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

Although 15350.00 and 15350.0 are two different BigDecimal values, BigDecimal.valueOf(15350.00) is constructing the BigDecimal using a Double. The double literals 15350.00 and 15350.0 both correspond to the same exact integer value, without the precision semantics of BigDecimal.

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