View Full Version : BigDecimal Sqrt?
Blacksage
Nov 30, 2007, 12:47 PM
There seems to be know Sqrt method in the BigDecimal Class. They Do have a power method but the power method only takes ints. So I can't try and do something to the .5 or 1/2 power. Dose anyone know of any other way I can find sqrt using Java BigDecimal? Thanks
jstrike
Dec 4, 2007, 08:40 AM
Try:
BigDecimal bd = new BigDecimal(343325027336.33);
Math.sqrt(bd.doubleValue());
Blacksage
Dec 4, 2007, 02:17 PM
Wouldn't that be the same thing as:
double x = Math.sqrt(343325027336.33);
jstrike
Dec 14, 2007, 08:12 AM
Wouldnt that be the same thing as:
double x = Math.sqrt(343325027336.33);
Yes, but he said he's using the BigDecimal class so you need to go from BigDecimal to double. There may be other BigDecimal methods that he's using prior to needing the square root.