* ext/bigdecimal/bigdecimal.c (VpCtoV): 1E1000...000 is interpreted as

Infinity.  [ruby-dev:36159]

* ext/bigdecimal/bigdecimal.c (VpPower): Infinity ** 1 returns
  Infinity instead of NaN.  [ruby-dev:36159]

* test/bigdecimal/test_bigdecimal.rb: add tests for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-09-18 13:48:21 +00:00
parent c3e2e0e53f
commit e040ff5530
3 changed files with 47 additions and 5 deletions

View file

@ -3944,7 +3944,12 @@ VpCtoV(Real *a, const char *int_chr, U_LONG ni, const char *frac, U_LONG nf, con
es = e*((S_INT)BASE_FIG);
e = e * 10 + exp_chr[i] - '0';
if(es>e*((S_INT)BASE_FIG)) {
return VpException(VP_EXCEPTION_INFINITY,"exponent overflow",0);
VpException(VP_EXCEPTION_INFINITY,"exponent overflow",0);
sign = 1;
if(int_chr[0] == '-') sign = -1;
if(signe > 0) VpSetInf(a, sign);
else VpSetZero(a, sign);
return 1;
}
++i;
}
@ -4633,8 +4638,20 @@ VpPower(Real *y, Real *x, S_INT n)
}
goto Exit;
}
if(!VpIsDef(x)) {
VpSetNaN(y); /* Not sure !!! */
if(VpIsNaN(x)) {
VpSetNaN(y);
goto Exit;
}
if(VpIsInf(x)) {
if(n==0) {
VpSetOne(y);
goto Exit;
}
if(n>0) {
VpSetInf(y, (n%2==0 || VpIsPosInf(x)) ? 1 : -1);
goto Exit;
}
VpSetZero(y, (n%2==0 || VpIsPosInf(x)) ? 1 : -1);
goto Exit;
}