summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/sample
diff options
context:
space:
mode:
authorshigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-25 02:27:33 +0000
committershigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-25 02:27:33 +0000
commit651f324a278e133a1cb809ec8ba9b0ff9e69d1d9 (patch)
tree4274191b73f4afe594f0791aebc094c94a83facd /ext/bigdecimal/sample
parentaafd6b025cdd52c3ef97796a6dc2bda02011f670 (diff)
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
Diffstat (limited to 'ext/bigdecimal/sample')
-rw-r--r--ext/bigdecimal/sample/pi.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/bigdecimal/sample/pi.rb b/ext/bigdecimal/sample/pi.rb
index cbb8448..833967a 100644
--- a/ext/bigdecimal/sample/pi.rb
+++ b/ext/bigdecimal/sample/pi.rb
@@ -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