summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-14 15:11:44 +0000
committershigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-14 15:11:44 +0000
commitf615358527c30b0fa3c9e4e80bde45ae9a59ad73 (patch)
treec463066d66e14cc1c118fb72f229f1c4be58acee
parent360a9445e4f0429d04b3f25d0ff2cf7962d496a2 (diff)
downloadruby-f615358527c30b0fa3c9e4e80bde45ae9a59ad73.tar.gz
ruby-f615358527c30b0fa3c9e4e80bde45ae9a59ad73.tar.xz
ruby-f615358527c30b0fa3c9e4e80bde45ae9a59ad73.zip
Bug fix: div method.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ext/bigdecimal/bigdecimal.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index bc0ba4c55..2f98bfd48 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -805,11 +805,13 @@ BigDecimal_div2(int argc, VALUE *argv, VALUE self)
U_LONG ix = (U_LONG)GetPositiveInt(n);
U_LONG mx = (ix+VpBaseFig()*2);
U_LONG pl = VpSetPrecLimit(0);
+
GUARD_OBJ(cv,VpCreateRbObject(mx,"0"));
GUARD_OBJ(av,GetVpValue(self,1));
GUARD_OBJ(bv,GetVpValue(b,1));
- mx = cv->MaxPrec+1;
- GUARD_OBJ(res,VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0"));
+ mx = av->Prec + bv->Prec + 2;
+ if(mx <= cv->MaxPrec) mx = cv->MaxPrec+1;
+ GUARD_OBJ(res,VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0"));
VpDivd(cv,res,av,bv);
VpSetPrecLimit(pl);
VpLeftRound(cv,VpGetRoundMode(),ix);
@@ -1418,7 +1420,7 @@ Init_bigdecimal(void)
*
*/
#ifdef _DEBUG
-static int gfDebug = 0; /* Debug switch */
+static int gfDebug = 1; /* Debug switch */
static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
#endif /* _DEBUG */