summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-09 14:49:41 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-09 14:49:41 +0000
commit520053232e76b03952b7e80be2c5a906132de195 (patch)
tree933475cdaac9fee15e9e4d9a1f750bf728be1a47
parent03ad923cdd130bd522e7b25e6f3958b3118aae01 (diff)
* ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/bigdecimal/bigdecimal.c4
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a8fa0cd3703..9cba04d1acf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Feb 9 23:48:25 2010 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.
+
Tue Feb 9 23:26:07 2010 Yusuke Endoh <mame@tsg.ne.jp>
* ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision.
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 67622ea5eb6..667f58128dc 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -882,7 +882,9 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
if(!b) return DoSomeOne(self,r,'/');
SAVE(b);
*div = b;
- mx =(a->MaxPrec + b->MaxPrec + 1) * VpBaseFig();
+ mx = a->Prec+abs(a->exponent);
+ if(mx<b->Prec+abs(b->exponent)) mx = b->Prec+abs(b->exponent);
+ mx =(mx + 1) * VpBaseFig();
GUARD_OBJ((*c),VpCreateRbObject(mx, "#0"));
GUARD_OBJ((*res),VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
VpDivd(*c, *res, a, b);