def pi(round_digits=nil)
      round_digits ||= self.precision
      if Trigonometry.pi_digits < round_digits
        # provisional implementation (very slow)
        lasts = 0
        t, s, n, na, d, da = Trigonometry.pi_cache
        num_class.context(self) do |local_context|
          local_context.precision = round_digits + 6
          tol = Rational(1,num_class.int_radix_power(local_context.precision+1))
          while (s-lasts)>tol
            lasts = s
            n, na = n+na, na+8
            d, da = d+da, da+32
            t = (t * n) / d
            s += t
          end
          Trigonometry.pi_value = num_class[s]
          Trigonometry.pi_digits = round_digits
          Trigonometry.pi_cache = [t, s, n, na, d, da]
        end
      end
      num_class.context(self, :precision=>round_digits){+Trigonometry.pi_value}
    end
def pi(round_digits=nil)
      round_digits ||= self.precision
      if Trigonometry.pi_digits < round_digits
        # provisional implementation (very slow)
        lasts = 0
        t, s, n, na, d, da = Trigonometry.pi_cache
        num_class.context(self) do |local_context|
          local_context.precision = round_digits + 6
          tol = Rational(1,num_class.int_radix_power(local_context.precision+1))
          while (s-lasts)>tol
            lasts = s
            n, na = n+na, na+8
            d, da = d+da, da+32
            t = (t * n) / d
            s += t
          end
          Trigonometry.pi_value = num_class[s]
          Trigonometry.pi_digits = round_digits
          Trigonometry.pi_cache = [t, s, n, na, d, da]
        end
      end
      num_class.context(self, :precision=>round_digits){+Trigonometry.pi_value}
    end
Pi