X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsqrtl.c;h=bf1b2d5faa74594c771578fa6bd692e619b1ff07;hb=471815b5cfb17e9a6b4ea985cc18edb87e26f30f;hp=4ca99d770a46b329fd04fdaf08b40c43ef6a8fff;hpb=267a39bafd249d7eb9c37df06dc6defcf41cb343;p=gnulib.git diff --git a/lib/sqrtl.c b/lib/sqrtl.c index 4ca99d770..bf1b2d5fa 100644 --- a/lib/sqrtl.c +++ b/lib/sqrtl.c @@ -1,7 +1,7 @@ /* Emulation for sqrtl. Contributed by Paolo Bonzini - Copyright 2002, 2003 Free Software Foundation, Inc. + Copyright 2002, 2003, 2007 Free Software Foundation, Inc. This file is part of gnulib. @@ -19,10 +19,13 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include + +/* Specification. */ #include -#include "mathl.h" +#include +#include "isnanl.h" /* A simple Newton-Raphson method. */ long double @@ -31,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);