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

  1. /* _Dtest function -- IEEE 754 version */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5.  
  6. _CRTIMP2 short _Dtest(double *px)
  7.     {    /* categorize *px */
  8.     unsigned short *ps = (unsigned short *)px;
  9.  
  10.     if ((ps[_D0] & _DMASK) == _DMAX << _DOFF)
  11.         return ((ps[_D0] & _DFRAC) != 0 || ps[_D1] != 0
  12.             || ps[_D2] != 0 || ps[_D3] != 0 ? NAN : INF);
  13.     else if ((ps[_D0] & ~_DSIGN) != 0 || ps[_D1] != 0
  14.         || ps[_D2] != 0 || ps[_D3] != 0)
  15.         return (FINITE);
  16.     else
  17.         return (0);
  18.     }
  19. _STD_END
  20.  
  21. /*
  22.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  23.  * Consult your license regarding permissions and restrictions.
  24.  */
  25.  
  26. /*
  27. 941029 pjp: added _STD machinery
  28.  */
  29.