s_isnan.c 838 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* @(#)s_isnan.c 5.1 93/09/24 */
  2. /*
  3. * ====================================================
  4. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
  5. *
  6. * Developed at SunPro, a Sun Microsystems, Inc. business.
  7. * Permission to use, copy, modify, and distribute this
  8. * software is freely granted, provided that this notice
  9. * is preserved.
  10. * ====================================================
  11. */
  12. /*
  13. * isnan(x) returns 1 is x is nan, else 0;
  14. * no branching!
  15. */
  16. #include "math.h"
  17. #include "math_private.h"
  18. #ifdef __STDC__
  19. int __isnan(double x)
  20. #else
  21. int __isnan(x)
  22. double x;
  23. #endif
  24. {
  25. int32_t hx,lx;
  26. EXTRACT_WORDS(hx,lx,x);
  27. hx &= 0x7fffffff;
  28. hx |= (u_int32_t)(lx|(-lx))>>31;
  29. hx = 0x7ff00000 - hx;
  30. return (int)(((u_int32_t)hx)>>31);
  31. }
  32. libm_hidden_def(__isnan)
  33. weak_alias(__isnan,isnan)
  34. libm_hidden_weak(isnan)