home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / g++ / values.h < prev    next >
C/C++ Source or Header  |  1993-08-20  |  6KB  |  198 lines

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