home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / xldtest.c < prev    next >
C/C++ Source or Header  |  1998-06-16  |  1KB  |  53 lines

  1. /* _LDtest function -- IEEE 754 version */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5.  
  6. #if !_DLONG
  7. _CRTIMP2 short _LDtest(long double *px)
  8.     {    /* categorize *px */
  9.     return (_Dtest((double *)px));
  10.     }
  11. #elif _LONG_DOUBLE_HAS_HIDDEN_BIT
  12. _CRTIMP2 short _LDtest(long double *px)
  13.     {    /* categorize *px -- SPARC */
  14.     unsigned short *ps = (unsigned short *)px;
  15.     short xchar = ps[_L0] & _LMASK;
  16.  
  17.     if (xchar == _LMAX)
  18.         return (ps[_L1] != 0 || ps[_L2] != 0 || ps[_L3] != 0
  19.             || ps[_L4] != 0 || ps[_L5] != 0 || ps[_L6] != 0
  20.             || ps[_L7] != 0 ? NAN : INF);
  21.     else if (0 < xchar || ps[_L1] || ps[_L2] || ps[_L3]
  22.         || ps[_L4] || ps[_L5] || ps[_L6] || ps[_L7])
  23.         return (FINITE);
  24.     else
  25.         return (0);
  26.     }
  27. #else    /*    _DLONG && !_LONG_DOUBLE_HAS_HIDDEN_BIT */
  28. _CRTIMP2 short _LDtest(long double *px)
  29.     {    /* categorize *px */
  30.     unsigned short *ps = (unsigned short *)px;
  31.     short xchar = ps[_L0] & _LMASK;
  32.  
  33.     if (xchar == _LMAX)
  34.         return ((ps[_L1] & 0x7fff) != 0 || ps[_L2] != 0
  35.             || ps[_L3] != 0 || ps[_L4] != 0 ? NAN : INF);
  36.     else if (0 < xchar || ps[_L1] != 0 || ps[_L2] || ps[_L3]
  37.         || ps[_L4])
  38.         return (FINITE);
  39.     else
  40.         return (0);
  41.     }
  42. #endif
  43. _STD_END
  44.  
  45. /*
  46.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  47.  * Consult your license regarding permissions and restrictions.
  48.  */
  49.  
  50. /*
  51. 941029 pjp: added _STD machinery
  52.  */
  53.