From: Tim Roberts Date: 2012-04-12T15:21:16+09:00 Subject: Re: BigDecimal precision on square root F�ldes L�szl� wrote: >What is the problem with this?: > >> BigDecimal("4").sqrt(10) >=> # >> BigDecimal("4").sqrt(11) >=> # > >`sqrt`'s parameter should be the precision, and for this operation 4 >should suffice (or not?). What are you complaining about? You asked for 10 digits of precision, and the answer you got is correct to 19 digits. >Why BigDecimal.sqrt is imprecise and why do I have to set a 11 digit >precision to get the proper value for sqrt(4)? BigDecimal.sqrt is implemented via Newton-Raphson iteration. That method converges very quickly, but not immediately. That's why the precision is a parameter. You got the correct answer, given the precision you requested. -- Tim Roberts, timr@probo.com Providenza & Boekelheide, Inc.