Subversion Repositories Kolibri OS

Rev

Rev 4872 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * isinf(x) returns 1 if x is infinity, else 0;
  3.  * no branching!
  4.  *
  5.  * isinf is a <math.h> macro in the C99 standard.  It was previously
  6.  * implemented as a function by newlib and is declared as such in
  7.  * <ieeefp.h>.  Newlib supplies it here as a function if the user
  8.  * chooses to use <ieeefp.h> or needs to link older code compiled with the
  9.  * previous <math.h> declaration.
  10.  */
  11.  
  12. #include "fdlibm.h"
  13. #include <ieeefp.h>
  14.  
  15. #ifndef _DOUBLE_IS_32BITS
  16.  
  17. int
  18. _DEFUN (isinf, (x),
  19.         double x)
  20. {
  21.         __int32_t hx,lx;
  22.         EXTRACT_WORDS(hx,lx,x);
  23.         hx &= 0x7fffffff;
  24.         hx |= (__uint32_t)(lx|(-lx))>>31;      
  25.         hx = 0x7ff00000 - hx;
  26.         return 1 - (int)((__uint32_t)(hx|(-hx))>>31);
  27. }
  28.  
  29. #endif /* _DOUBLE_IS_32BITS */
  30.