diff options
author | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-17 14:00:42 +0000 |
---|---|---|
committer | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-17 14:00:42 +0000 |
commit | 57c6f017a02da946781589924595e2f67375131a (patch) | |
tree | 833a0431e0e21d0d00ca3c171609ef1964b4678a | |
parent | e07677d30835819be5733ac53c118879ea10ac1b (diff) | |
download | ruby-57c6f017a02da946781589924595e2f67375131a.tar.gz |
Bug in negative.exp(n) reported by Hitoshi Miyazaki fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 29bc1e5ca4..7b23826ac1 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -9,6 +9,8 @@ * of this BigDecimal distribution. * * NOTES: + * 2003-04-17 + * Bug in negative.exp(n) reported by Hitoshi Miyazaki fixed. * 2003-03-28 * V1.0 checked in to CVS(ruby/ext/bigdecimal). * use rb_str2cstr() instead of STR2CSTR(). @@ -4007,6 +4009,7 @@ VpExp(Real *y, Real *x) U_LONG p; U_LONG nc; U_LONG i; + short fNeg=0; if(!VpIsDef(x)) { VpSetNaN(y); /* Not sure */ @@ -4022,6 +4025,9 @@ VpExp(Real *y, Real *x) if(p<maxnr) nc = maxnr; else nc = p; + fNeg = x->sign; + if(fNeg<0) x->sign = -fNeg; + /* allocate temporally variables */ z = VpAlloc(p, "#1"); div = VpAlloc(p, "#1"); @@ -4047,9 +4053,16 @@ VpExp(Real *y, Real *x) VpAsgn(y, div, 1); /* y = y(new) */ } while(((!VpIsZero(c)) &&(c->exponent >= 0 ||((U_LONG)(-c->exponent)) <= y->MaxPrec)) && i<nc - ); + ); + + if(fNeg < 0) { + x->sign = fNeg; + VpDivd(div, r, VpConstOne, y); + VpAsgn(y, div, 1); + } Exit: + #ifdef _DEBUG if(gfDebug) { VPrint(stdout, "vpexp e=%\n", y); |