`sqrt`'s parameter should be the precision, and for this operation 4
should suffice (or not?). Documentation on BigDecimal.sqrt is a tad bit
suboptimal, it states that `n` for `sqrt(n)` is optional, however it is
a must.
BigDecimal("4").sqrt
ArgumentError: wrong number of arguments(0 for 1)
from (pry):35:in `sqrt'
Why BigDecimal.sqrt is imprecise and why do I have to set a 11 digit
precision to get the proper value for sqrt(4)?
`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.
···
Földes László <lists@ruby-forum.com> wrote:
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.