summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bigdecimal/bigdecimal.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 099331682b..029c6f4c9d 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2026,7 +2026,7 @@ VpAsgn(Real *c, Real *a, int isw)
if(c->Prec < a->Prec) {
VpInternalRound(c,n,(n>0)?a->frac[n-1]:0,a->frac[n]);
} else {
- VpLimitRound(c,0);
+ VpLimitRound(c,0);
}
}
} else {
@@ -2589,12 +2589,13 @@ VpMult(Real *c, Real *a, Real *b)
}
}
}
-
- VpNmlz(c); /* normalize the result */
if(w != NULL) { /* free work variable */
+ VpNmlz(c);
VpAsgn(w, c, 1);
VpFree(c);
c = w;
+ } else {
+ VpLimitRound(c,0);
}
Exit:
@@ -3821,7 +3822,8 @@ static int
VpLimitRound(Real *c,U_LONG ixDigit)
{
U_LONG ix = VpGetPrecLimit();
- if(!ix) return 0;
+ if(!VpNmlz(c)) return -1;
+ if(!ix) return 0;
if(!ixDigit) ixDigit = c->Prec-1;
if((ix+BASE_FIG-1)/BASE_FIG > ixDigit+1) return 0;
return VpLeftRound(c,VpGetRoundMode(),ix);
@@ -3832,7 +3834,6 @@ VpInternalRound(Real *c,int ixDigit,U_LONG vPrev,U_LONG v)
{
int f = 0;
- if(!VpNmlz(c)) return;
if(VpLimitRound(c,ixDigit)) return;
if(!v) return;