How to Convert Bigdecimal to Double in Java?

How we convert BigDecimal into Double in java? I have a requirement where we have to use Double as argument but we are getting BigDecimal so i have to convert BigDecimal into Double.

7

3 Answers

You need to use the doubleValue() method to get the double value from a BigDecimal object.

BigDecimal bd; // the value you get
double d = bd.doubleValue(); // The double you want
2

You can convert BigDecimal to double using .doubleValue(). But believe me, don't use it if you have currency manipulations. It should always be performed on BigDecimal objects directly. Precision loss in these calculations are big time problems in currency related calculations.

0

Use doubleValue method present in BigDecimal class :

double doubleValue()

Converts this BigDecimal to a double.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest