X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsqrtl.c;h=bf1b2d5faa74594c771578fa6bd692e619b1ff07;hb=471815b5cfb17e9a6b4ea985cc18edb87e26f30f;hp=e8e2b32fbd7f34c97e95d3d41f0549755b11f9c6;hpb=d0723a1652f9f002aa800cd618fd52717b980b18;p=gnulib.git diff --git a/lib/sqrtl.c b/lib/sqrtl.c index e8e2b32fb..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. @@ -17,12 +17,15 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + 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);