X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsqrtl.c;h=bf1b2d5faa74594c771578fa6bd692e619b1ff07;hb=5d0b385594bc914e6233988bfb6bc1b92a2184b5;hp=3702f027effe58fd2f349f88ee2dee1405e80723;hpb=e1123c2f4fedae90435426a82a05cf2e3233e97d;p=gnulib.git diff --git a/lib/sqrtl.c b/lib/sqrtl.c index 3702f027e..bf1b2d5fa 100644 --- a/lib/sqrtl.c +++ b/lib/sqrtl.c @@ -25,6 +25,7 @@ #include #include +#include "isnanl.h" /* A simple Newton-Raphson method. */ long double @@ -33,12 +34,16 @@ sqrtl(long double x) long double delta, y; int exponent; + /* Check for NaN */ + if (isnanl (x)) + return x; + /* Check for negative numbers */ if (x < 0.0L) return (long double) sqrt(-1); - /* Check for zero, NANs and infinites */ - if (x + x == x || x != x) + /* Check for zero and infinites */ + if (x + x == x) return x; frexpl (x, &exponent);