From 57c6f017a02da946781589924595e2f67375131a Mon Sep 17 00:00:00 2001 From: shigek Date: Thu, 17 Apr 2003 14:00:42 +0000 Subject: 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 --- ext/bigdecimal/bigdecimal.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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(psign; + 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)) && isign = fNeg; + VpDivd(div, r, VpConstOne, y); + VpAsgn(y, div, 1); + } Exit: + #ifdef _DEBUG if(gfDebug) { VPrint(stdout, "vpexp e=%\n", y); -- cgit v1.2.3