diff options
author | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-14 15:11:44 +0000 |
---|---|---|
committer | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-14 15:11:44 +0000 |
commit | 588c9c66bf99411d3fb41f0f68b7b6d24772f670 (patch) | |
tree | c463066d66e14cc1c118fb72f229f1c4be58acee /ext/bigdecimal | |
parent | 2f2cb647c1c91d76ec3f6739aaddce96560a63f5 (diff) |
Bug fix: div method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index bc0ba4c55d..2f98bfd487 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 */ |