]> git.saurik.com Git - apple/libc.git/blobdiff - gen/isnan.c
Libc-391.2.3.tar.gz
[apple/libc.git] / gen / isnan.c
index bcf2de1c6ee86fb39dcd7a1b1e311c0b476b291a..300d959faaba23a7dfe2c15b4497ca80eabf355d 100644 (file)
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
-/* @(#)s_isnan.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice 
- * is preserved.
- * ====================================================
- */
-
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
-#endif
-
-/*
- * isnan(x) returns 1 is x is nan, else 0;
- * no branching!
- */
-
-#include <sys/types.h>
-
-typedef union
-{
-  double value;
-  struct
-  {
-#if defined(__BIG_ENDIAN__)
-    u_int32_t msw;
-    u_int32_t lsw;
-#else
-    u_int32_t lsw;
-    u_int32_t msw;
-#endif
-  } parts;
-} ieee_double_shape_type;
-/* Get two 32 bit ints from a double.  */
-
-#define EXTRACT_WORDS(ix0,ix1,d)                               \
-do {                                                           \
-  ieee_double_shape_type ew_u;                                 \
-  ew_u.value = (d);                                            \
-  (ix0) = ew_u.parts.msw;                                      \
-  (ix1) = ew_u.parts.lsw;                                      \
-} while (0)
 
+#include <math.h>
 
-#ifdef __STDC__
-       int isnan(double x)
-#else
-       int isnan(x)
-       double x;
-#endif
+/* 3BSD compatibility function */
+#undef isnan
+int
+isnan(double d)
 {
-       int32_t hx,lx;
-       EXTRACT_WORDS(hx,lx,x);
-       hx &= 0x7fffffff;
-       hx |= (u_int32_t)(lx|(-lx))>>31;        
-       hx = 0x7ff00000 - hx;
-       return (int)((u_int32_t)(hx))>>31;
+    return __isnand(d);
 }