home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / hobby / palmoon / palmoon.EXE / s_isnan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-16  |  1.3 KB  |  49 lines

  1. // 15 August 1997, Rick Huebner:  Small changes made to adapt for MathLib
  2.  
  3. /* @(#)s_isnan.c 5.1 93/09/24 */
  4. /*
  5.  * ====================================================
  6.  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  7.  *
  8.  * Developed at SunPro, a Sun Microsystems, Inc. business.
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software is freely granted, provided that this notice
  11.  * is preserved.
  12.  * ====================================================
  13.  */
  14.  
  15. #if defined(LIBM_SCCS) && !defined(lint)
  16. static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
  17. #endif
  18.  
  19. /*
  20.  * isnan(x) returns 1 is x is nan, else 0;
  21.  * no branching!
  22.  */
  23.  
  24. #include "math.h"
  25. #include "math_private.h"
  26.  
  27. #ifdef __STDC__
  28.     int __isnan(double x)
  29. #else
  30.     int __isnan(x)
  31.     double x;
  32. #endif
  33. {
  34.     int32_t hx,lx;
  35.     EXTRACT_WORDS(hx,lx,x);
  36.     hx &= 0x7fffffff;
  37.     hx |= (u_int32_t)(lx|(-lx))>>31;
  38.     hx = 0x7ff00000 - hx;
  39. // Minor bug: This returned -1 instead of 1 for true, due to casting
  40. // from uint to int before shift (asr) instead of after (lsr)
  41. //    return (int)((u_int32_t)(hx))>>31;
  42.     return (int)(((u_int32_t)(hx))>>31);
  43. }
  44. weak_alias (__isnan, isnan)
  45. #ifdef NO_LONG_DOUBLE
  46. strong_alias (__isnan, __isnanl)
  47. weak_alias (__isnan, isnanl)
  48. #endif
  49.