0

I have an equation that involves lots of divisions to produce a number (say) "X" then raising "X" to the power 0.5 (square rooted) gives me the final answer "Y". My question is: If I use BigDecimal to do the divisions and multiplications until I get "X" then I convert "X" to double in-order to use the .pow() method to get Y, (I know I might loose precision in the last step) but how bad is that idea? I am saying so because I have seen people having troubles in raising a BigDecimal to a double value.

Any recommendations/corrections are welcome.

OAH
  • 309
  • 3
  • 11
  • 1
    Have you thought of implementing the sqrt() for BigDecimal? For example, check the http://stackoverflow.com/questions/13649703/square-root-of-bigdecimal-in-java and linked questions. – Oleg Estekhin Mar 24 '14 at 06:30

1 Answers1

1

It is not bad idea. You can convert BigDecimal into double for this purpose.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40