summaryrefslogtreecommitdiff
path: root/lib/sqrtl.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2007-03-26 22:26:05 +0000
committerBruno Haible <bruno@clisp.org>2007-03-26 22:26:05 +0000
commit55eed6bbc87934f2db04981e6f0f1773ff77974f (patch)
tree3efbacdf3038c4f35632f5d0c82ba7ab89db6d46 /lib/sqrtl.c
parent9afb597f0d5a27ebff90bc4e493e30ab15791bf0 (diff)
downloadgnulib-55eed6bbc87934f2db04981e6f0f1773ff77974f.tar.gz
Better support of signalling NaNs.
Diffstat (limited to 'lib/sqrtl.c')
-rw-r--r--lib/sqrtl.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqrtl.c b/lib/sqrtl.c
index 3702f027ef..bf1b2d5faa 100644
--- a/lib/sqrtl.c
+++ b/lib/sqrtl.c
@@ -25,6 +25,7 @@
#include <math.h>
#include <float.h>
+#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);