summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);