summaryrefslogtreecommitdiff log msg author committer range
diff options
 context: 12345678910152025303540 space: includeignore mode: unifiedssdiffstat only
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb1
-rw-r--r--ext/bigdecimal/sample/pi.rb10
2 files changed, 5 insertions, 6 deletions
 diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rbindex d9b7ae3131..369fe3fdd0 100644--- a/ext/bigdecimal/lib/bigdecimal/util.rb+++ b/ext/bigdecimal/lib/bigdecimal/util.rb@@ -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<=0diff --git a/ext/bigdecimal/sample/pi.rb b/ext/bigdecimal/sample/pi.rbindex cbb8448a38..833967a583 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