home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gccdist / gcc / include / values.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-29  |  5.8 KB  |  184 lines

  1. /* This may look like C code, and it really is */
  2. /* Adapted from values.h, libg++ 2.2.2 */
  3. /* 
  4. Copyright (C) 1988 Free Software Foundation
  5.     written by Doug Lea (dl@rocky.oswego.edu)
  6.  
  7. This file is part of the GNU C++ Library.  This library is free
  8. software; you can redistribute it and/or modify it under the terms of
  9. the GNU Library General Public License as published by the Free
  10. Software Foundation; either version 2 of the License, or (at your
  11. option) any later version.  This library is distributed in the hope
  12. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  13. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  14. PURPOSE.  See the GNU Library General Public License for more details.
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20.  
  21. #ifndef _values_h
  22. #define _values_h 1
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #define BITSPERBYTE 8
  29. #define BITS(type)  (BITSPERBYTE * (int)sizeof(type))
  30.  
  31. #define CHARBITS    BITS(char)
  32. #define SHORTBITS   BITS(short)
  33. #define INTBITS     BITS(int)
  34. #define LONGBITS    BITS(long)
  35. #define PTRBITS     BITS(char*)
  36. #define DOUBLEBITS  BITS(double)
  37. #define FLOATBITS   BITS(float)
  38.  
  39. #define MINSHORT    ((short)(1 << (SHORTBITS - 1)))
  40. #define MININT      (1 << (INTBITS - 1))
  41. #define MINLONG     (1L << (LONGBITS - 1))
  42.  
  43. #define MAXSHORT    ((short)~MINSHORT)
  44. #define MAXINT      (~MININT)
  45. #define MAXLONG     (~MINLONG)
  46.  
  47. #define HIBITS    MINSHORT
  48. #define HIBITL    MINLONG
  49.  
  50. #if defined(sun) || defined(hp300) || defined(hpux) || defined(masscomp) || defined(sgi)
  51. #ifdef masscomp
  52. #define MAXDOUBLE                            \
  53. ({                                    \
  54.   double maxdouble_val;                            \
  55.                                     \
  56.   __asm ("fmove%.d #0x7fefffffffffffff,%0"    /* Max double */    \
  57.      : "=f" (maxdouble_val)                        \
  58.      : /* no inputs */);                        \
  59.   maxdouble_val;                            \
  60. })
  61. #define MAXFLOAT ((float) 3.40e+38)
  62. #else
  63. #define MAXDOUBLE   1.79769313486231470e+308
  64. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  65. #endif
  66. #define MINDOUBLE   4.94065645841246544e-324
  67. #define MINFLOAT    ((float)1.40129846432481707e-45)
  68. #define _IEEE       1
  69. #define _DEXPLEN    11
  70. #define _FEXPLEN    8
  71. #define _HIDDENBIT  1
  72. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  73. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  74. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  75. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  76.  
  77. #elif defined(sony) 
  78. #define MAXDOUBLE   1.79769313486231470e+308
  79. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  80. #define MINDOUBLE   2.2250738585072010e-308
  81. #define MINFLOAT    ((float)1.17549435e-38)
  82. #define _IEEE       1
  83. #define _DEXPLEN    11
  84. #define _FEXPLEN    8
  85. #define _HIDDENBIT  1
  86. #define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  87. #define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  88. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  89. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  90.  
  91. #elif defined(sequent)
  92. extern double _maxdouble, _mindouble;
  93. extern float _maxfloat, _minfloat;
  94. #define MAXDOUBLE    _maxdouble
  95. #define MAXFLOAT    _maxfloat
  96. #define MINDOUBLE    _mindouble
  97. #define MINFLOAT    _minfloat
  98. #define _IEEE       1
  99. #define _DEXPLEN    11
  100. #define _FEXPLEN    8
  101. #define _HIDDENBIT  1
  102. #define DMINEXP     (-(DMAXEXP - 3))
  103. #define FMINEXP     (-(FMAXEXP - 3))
  104. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  105. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  106.  
  107. #elif defined(i386)
  108. #define MAXDOUBLE   1.79769313486231570e+308
  109. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  110. #define MINDOUBLE   2.22507385850720140e-308
  111. #define MINFLOAT    ((float)1.17549435082228750e-38)
  112. #define _IEEE       0
  113. #define _DEXPLEN    11
  114. #define _FEXPLEN    8
  115. #define _HIDDENBIT  1
  116. #define DMINEXP     (-DMAXEXP)
  117. #define FMINEXP     (-FMAXEXP)
  118. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  119. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  120.  
  121. /* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
  122. #elif defined(m88k)
  123.     /* These are "good" guesses ...
  124.        I'll figure out the true mins and maxes later, at the time I find
  125.        out the mins and maxes that the compiler can tokenize. */
  126. #define MAXDOUBLE   1.79769313486231e+308
  127. #define MAXFLOAT    ((float)3.40282346638528e+38)
  128. #define MINDOUBLE   2.22507385850720e-308
  129. #define MINFLOAT    ((float)1.17549435082228e-38)
  130. #define _IEEE       1
  131. #define _DEXPLEN    11
  132. #define _FEXPLEN    8
  133. #define _HIDDENBIT  1
  134. #define DMINEXP     (1-DMAXEXP)
  135. #define FMINEXP     (1-FMAXEXP)
  136. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  137. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  138.  
  139. #elif defined(convex)
  140. #define MAXDOUBLE   8.9884656743115785e+306
  141. #define MAXFLOAT    ((float) 1.70141173e+38)
  142. #define MINDOUBLE   5.5626846462680035e-308
  143. #define MINFLOAT    ((float) 2.93873588e-39)
  144. #define _IEEE       0
  145. #define _DEXPLEN    11
  146. #define _FEXPLEN    8
  147. #define _HIDDENBIT  1
  148. #define DMINEXP     (-DMAXEXP)
  149. #define FMINEXP     (-FMAXEXP)
  150. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  151. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  152.  
  153. // #elif defined(vax)
  154. // use vax versions by default -- they seem to be the most conservative
  155. #else 
  156.  
  157. #define MAXDOUBLE   1.701411834604692293e+38
  158. #define MINDOUBLE   (2.938735877055718770e-39)
  159.  
  160. #define MAXFLOAT    1.7014117331926443e+38
  161. #define MINFLOAT    2.9387358770557188e-39
  162.  
  163. #define _IEEE       0
  164. #define _DEXPLEN    8
  165. #define _FEXPLEN    8
  166. #define _HIDDENBIT  1
  167. #define DMINEXP     (-DMAXEXP)
  168. #define FMINEXP     (-FMAXEXP)
  169. #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
  170. #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
  171. #endif
  172.  
  173. #define DSIGNIF     (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
  174. #define FSIGNIF     (FLOATBITS  - _FEXPLEN + _HIDDENBIT - 1)
  175. #define DMAXPOWTWO  ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
  176. #define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
  177.  
  178. #ifdef __cplusplus
  179. }
  180. #endif
  181.  
  182. #endif
  183.  
  184.