s_isinf.c 728 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Written by J.T. Conklin <jtc@netbsd.org>.
  3. * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
  4. * Public domain.
  5. */
  6. #if defined(LIBM_SCCS) && !defined(lint)
  7. static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
  8. #endif
  9. /*
  10. * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
  11. * no branching!
  12. */
  13. #include "math.h"
  14. #include "math_private.h"
  15. libm_hidden_proto(__isinf)
  16. int
  17. __isinf (double x)
  18. {
  19. int32_t hx,lx;
  20. EXTRACT_WORDS(hx,lx,x);
  21. lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
  22. lx |= -lx;
  23. return ~(lx >> 31) & (hx >> 30);
  24. }
  25. libm_hidden_def (__isinf)
  26. weak_alias (__isinf, isinf)
  27. #ifdef NO_LONG_DOUBLE
  28. strong_alias (__isinf, __isinfl)
  29. weak_alias (__isinf, isinfl)
  30. #endif