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:
parent
e0a51801f8
commit
4b159597af
@ -3624,18 +3624,23 @@ VpSqrt(Real *y, Real *x)
|
|||||||
S_LONG nr;
|
S_LONG nr;
|
||||||
double val;
|
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 ? */
|
/* Negative ? */
|
||||||
if(VpGetSign(x) < 0) {
|
if(VpGetSign(x) < 0) {
|
||||||
VpSetNaN(y);
|
VpSetNaN(y);
|
||||||
return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(negative value)",0);
|
return VpException(VP_EXCEPTION_OP,"(VpSqrt) SQRT(negative value)",0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NaN or Infinity ? */
|
|
||||||
if(!VpHasVal(x)) {
|
|
||||||
VpAsgn(y,x,1);
|
|
||||||
goto Exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* One ? */
|
/* One ? */
|
||||||
if(VpIsOne(x)) {
|
if(VpIsOne(x)) {
|
||||||
VpSetOne(y);
|
VpSetOne(y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user