Skip to content

Commit 1e778b3

Browse files
committed
temp workaround BigDecimal division issue [Bug ruby#9316]
1 parent ff9a893 commit 1e778b3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,7 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
12221222
*div = b;
12231223
mx = a->Prec + vabs(a->exponent);
12241224
if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
1225+
if (mx<3) mx = 3;
12251226
mx =(mx + 1) * VpBaseFig();
12261227
GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
12271228
GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
@@ -1323,6 +1324,7 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
13231324

13241325
mx = a->Prec + vabs(a->exponent);
13251326
if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
1327+
if (mx<3) mx = 3;
13261328
mx = (mx + 1) * VpBaseFig();
13271329
GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
13281330
GUARD_OBJ(res, VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));

0 commit comments

Comments
 (0)