1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

sqrt() error checking bug fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shigek 2003-08-26 13:22:32 +00:00
parent e0a51801f8
commit 4b159597af

View file

@ -3624,18 +3624,23 @@ VpSqrt(Real *y, Real *x)
S_LONG nr;
double val;
/* Zero, NaN or Infinity ? */
if(!VpHasVal(x)) {
if(VpIsZero(x)||VpGetSign(x)>0) {
VpAsgn(y,x,1);
goto Exit;
}
VpSetNaN(y);
return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(NaN or negative value)",0);
goto Exit;
}
/* Negative ? */
if(VpGetSign(x) < 0) {
VpSetNaN(y);
return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(negative value)",0);
}
/* NaN or Infinity ? */
if(!VpHasVal(x)) {
VpAsgn(y,x,1);
goto Exit;
}
/* One ? */
if(VpIsOne(x)) {
VpSetOne(y);