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

  1. /* values used by math functions -- IEEE 754 long version */
  2. #include "wctype.h"
  3. #include "xmath.h"
  4. _STD_BEGIN
  5.  
  6. #if _DLONG    /* long double has unique representation */
  7.         /* macros */
  8. #define NBITS    64
  9.  #if _D0
  10.   #define INIT(w0, w1)        {0, 0, 0, w1, w0}
  11.   #define INIT3(w0, w1, wn)    {wn, 0, 0, w1, w0}
  12.  #else
  13.   #define INIT(w0, w1)        {w0, w1, 0, 0, 0}
  14.   #define INIT3(w0, w1, wn)    {w0, w1, 0, 0, wn}
  15.  #endif
  16.         /* static data */
  17. _CRTIMP2 const _Dconst _LDenorm = {INIT3(0, 0, 1)};
  18. _CRTIMP2 const _Dconst _LEps = {INIT(_LBIAS - NBITS - 1, 0x8000)};
  19.  #if _LONG_DOUBLE_HAS_HIDDEN_BIT
  20. _CRTIMP2 const _Dconst _LInf = {INIT(_LMAX, 0)};
  21. _CRTIMP2 const _Dconst _LNan = {INIT(_LSIGN | _LMAX, 0x8000)};
  22. _CRTIMP2 const _Dconst _LSnan = {INIT(_LSIGN | _LMAX, 0)};
  23.  #else
  24. _CRTIMP2 const _Dconst _LInf = {INIT(_LMAX, 0x8000)};
  25. _CRTIMP2 const _Dconst _LNan = {INIT(_LSIGN | _LMAX, 0xc000)};
  26. _CRTIMP2 const _Dconst _LSnan = {INIT(_LSIGN | _LMAX, 0x8000)};
  27.  #endif
  28. _CRTIMP2 const _Dconst _LRteps = {INIT(_LBIAS - NBITS / 2, 0x8000)};
  29. _CRTIMP2 const long double _LXbig = (NBITS + 1) * 347L / 1000;
  30.  
  31.  #if defined(__CENTERLINE__)
  32.   #define _DYNAMIC_INIT_CONST(x) \
  33.     (x._L = *(long double *)(void *)(x._W))
  34. long double _centerline_long_double_dynamic_init =
  35. _DYNAMIC_INIT_CONST(_LEps),
  36. _DYNAMIC_INIT_CONST(_LInf),
  37. _DYNAMIC_INIT_CONST(_LNan),
  38. _DYNAMIC_INIT_CONST(_LRteps);
  39.  #endif
  40. #else    /* long double same representation as double */
  41.         /* macros */
  42.  #define NBITS    (48 + _DOFF)
  43.  #if _D0
  44.   #define INIT(w0)        {0, 0, 0, w0}
  45.   #define INIT2(w0, w1)    {w1, 0, 0, w0}
  46.  #else
  47.   #define INIT(w0)        {w0, 0, 0, 0}
  48.   #define INIT2(w0, w1)    {w0, 0, 0, w1}
  49.  #endif
  50.         /* static data */
  51. _CRTIMP2 const _Dconst _LDenorm = {INIT2(0, 1)};
  52. _CRTIMP2 const _Dconst _LEps = {INIT((_DBIAS - NBITS - 1) << _DOFF)};
  53. _CRTIMP2 const _Dconst _LInf = {INIT(_DMAX << _DOFF)};
  54. _CRTIMP2 const _Dconst _LNan = {INIT(_DSIGN | (_DMAX << _DOFF)
  55.     | (1 << _DOFF - 1))};
  56. _CRTIMP2 const _Dconst _LRteps = {INIT((_DBIAS - NBITS / 2) << _DOFF)};
  57. _CRTIMP2 const _Dconst _LSnan = {INIT(_DSIGN | (_DMAX << _DOFF))};
  58. _CRTIMP2 const long double _LXbig = (NBITS + 1) * 347L / 1000;
  59.  
  60.  #if defined(__CENTERLINE__)
  61.   #define _DYNAMIC_INIT_CONST(x) \
  62.     (x._D = *(long double *)(void *)(x._W))
  63. long double _centerline_long_double_dynamic_inits =
  64. _DYNAMIC_INIT_CONST(_LEps),
  65. _DYNAMIC_INIT_CONST(_LInf),
  66. _DYNAMIC_INIT_CONST(_LNan),
  67. _DYNAMIC_INIT_CONST(_LRteps);
  68.  #endif
  69. #endif
  70. _STD_END
  71.  
  72. /*
  73.  * Copyright (c) 1994 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  74.  * Consult your license regarding permissions and restrictions.
  75.  */
  76.  
  77. /*
  78. 941029 pjp: added _STD machinery
  79. 950222 pjp: added signaling NaN, denorm minimum for C++
  80. 950506 pjp: corrected _LDenorm spelling
  81. 951005 pjp: added _DLONG logic
  82. 951115 pjp: corrected _LXbig type
  83.  */
  84.