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
This commit is contained in:
parent
e07677d308
commit
57c6f017a0
@ -9,6 +9,8 @@
|
|||||||
* of this BigDecimal distribution.
|
* of this BigDecimal distribution.
|
||||||
*
|
*
|
||||||
* NOTES:
|
* NOTES:
|
||||||
|
* 2003-04-17
|
||||||
|
* Bug in negative.exp(n) reported by Hitoshi Miyazaki fixed.
|
||||||
* 2003-03-28
|
* 2003-03-28
|
||||||
* V1.0 checked in to CVS(ruby/ext/bigdecimal).
|
* V1.0 checked in to CVS(ruby/ext/bigdecimal).
|
||||||
* use rb_str2cstr() instead of STR2CSTR().
|
* use rb_str2cstr() instead of STR2CSTR().
|
||||||
@ -4007,6 +4009,7 @@ VpExp(Real *y, Real *x)
|
|||||||
U_LONG p;
|
U_LONG p;
|
||||||
U_LONG nc;
|
U_LONG nc;
|
||||||
U_LONG i;
|
U_LONG i;
|
||||||
|
short fNeg=0;
|
||||||
|
|
||||||
if(!VpIsDef(x)) {
|
if(!VpIsDef(x)) {
|
||||||
VpSetNaN(y); /* Not sure */
|
VpSetNaN(y); /* Not sure */
|
||||||
@ -4022,6 +4025,9 @@ VpExp(Real *y, Real *x)
|
|||||||
if(p<maxnr) nc = maxnr;
|
if(p<maxnr) nc = maxnr;
|
||||||
else nc = p;
|
else nc = p;
|
||||||
|
|
||||||
|
fNeg = x->sign;
|
||||||
|
if(fNeg<0) x->sign = -fNeg;
|
||||||
|
|
||||||
/* allocate temporally variables */
|
/* allocate temporally variables */
|
||||||
z = VpAlloc(p, "#1");
|
z = VpAlloc(p, "#1");
|
||||||
div = VpAlloc(p, "#1");
|
div = VpAlloc(p, "#1");
|
||||||
@ -4047,9 +4053,16 @@ VpExp(Real *y, Real *x)
|
|||||||
VpAsgn(y, div, 1); /* y = y(new) */
|
VpAsgn(y, div, 1); /* y = y(new) */
|
||||||
} while(((!VpIsZero(c)) &&(c->exponent >= 0 ||((U_LONG)(-c->exponent)) <= y->MaxPrec)) &&
|
} while(((!VpIsZero(c)) &&(c->exponent >= 0 ||((U_LONG)(-c->exponent)) <= y->MaxPrec)) &&
|
||||||
i<nc
|
i<nc
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(fNeg < 0) {
|
||||||
|
x->sign = fNeg;
|
||||||
|
VpDivd(div, r, VpConstOne, y);
|
||||||
|
VpAsgn(y, div, 1);
|
||||||
|
}
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if(gfDebug) {
|
if(gfDebug) {
|
||||||
VPrint(stdout, "vpexp e=%\n", y);
|
VPrint(stdout, "vpexp e=%\n", y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user