mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Spec for div changed.
add,sub,mult,div now can specify exact digits number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aafd6b025c
commit
651f324a27
2 changed files with 5 additions and 6 deletions
|
@ -63,7 +63,6 @@ end
|
|||
|
||||
class Rational < Numeric
|
||||
# Convert Rational to BigDecimal
|
||||
# to_d returns an array [quotient,residue]
|
||||
def to_d(nFig=0)
|
||||
num = self.numerator.to_s
|
||||
if nFig<=0
|
||||
|
|
|
@ -20,9 +20,9 @@ def big_pi(sig) # sig: Number of significant figures
|
|||
k = BigDecimal::new("1")
|
||||
w = BigDecimal::new("1")
|
||||
t = BigDecimal::new("-80")
|
||||
while (u.exponent >= exp)
|
||||
while (u.nonzero? && u.exponent >= exp)
|
||||
t = t*m25
|
||||
u,r = t.div(k,sig)
|
||||
u = t.div(k,sig)
|
||||
pi = pi + u
|
||||
k = k+two
|
||||
end
|
||||
|
@ -31,9 +31,9 @@ def big_pi(sig) # sig: Number of significant figures
|
|||
k = BigDecimal::new("1")
|
||||
w = BigDecimal::new("1")
|
||||
t = BigDecimal::new("956")
|
||||
while (u.exponent >= exp )
|
||||
t,r = t.div(m57121,sig)
|
||||
u,r = t.div(k,sig)
|
||||
while (u.nonzero? && u.exponent >= exp )
|
||||
t = t.div(m57121,sig)
|
||||
u = t.div(k,sig)
|
||||
pi = pi + u
|
||||
k = k+two
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue