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