All pastes #915317 Raw Edit

Something

public ruby v1 · immutable
#915317 ·published 2008-02-23 18:22 UTC
rendered paste body
# File bigdecimal/lib/bigdecimal/math.rb, line 156  def log(x, prec)    raise ArgumentError, "Zero or negative argument for log" if x <= 0 || prec <= 0    return x if x.infinite? || x.nan?    one = BigDecimal("1")    two = BigDecimal("2")    n  = prec + BigDecimal.double_fig    x  = (x - one).div(x + one,n)    x2 = x.mult(x,n)    y  = x    d  = y    i = one    while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)      m = BigDecimal.double_fig if m < BigDecimal.double_fig      x  = x2.mult(x,n)      i += two      d  = x.div(i,m)      y += d    end    y*two  end