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:
parent
e0a51801f8
commit
4b159597af
1 changed files with 11 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue