annotate lib/float+.h @ 423:079d43b6967b 3.0-beta2 3.0-beta2

Added missing file
author lost@l-w.ca
date Sun, 19 Sep 2010 01:44:47 -0600
parents 3c2e1f24cc7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
421
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
1 /* Supplemental information about the floating-point formats.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2007.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
4
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
7 the Free Software Foundation; either version 3, or (at your option)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
8 any later version.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
9
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
13 GNU General Public License for more details.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
14
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
16 along with this program; if not, write to the Free Software Foundation,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
18
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
19 #ifndef _FLOATPLUS_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
20 #define _FLOATPLUS_H
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
21
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
22 #include <float.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
23 #include <limits.h>
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
24
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
25 /* Number of bits in the mantissa of a floating-point number, including the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
26 "hidden bit". */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
27 #if FLT_RADIX == 2
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
28 # define FLT_MANT_BIT FLT_MANT_DIG
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
29 # define DBL_MANT_BIT DBL_MANT_DIG
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
30 # define LDBL_MANT_BIT LDBL_MANT_DIG
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
31 #elif FLT_RADIX == 4
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
32 # define FLT_MANT_BIT (FLT_MANT_DIG * 2)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
33 # define DBL_MANT_BIT (DBL_MANT_DIG * 2)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
34 # define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
35 #elif FLT_RADIX == 16
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
36 # define FLT_MANT_BIT (FLT_MANT_DIG * 4)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
37 # define DBL_MANT_BIT (DBL_MANT_DIG * 4)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
38 # define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
39 #endif
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
40
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
41 /* Bit mask that can be used to mask the exponent, as an unsigned number. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
42 #define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
43 #define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
44 #define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
45
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
46 /* Number of bits used for the exponent of a floating-point number, including
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
47 the exponent's sign. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
48 #define FLT_EXP_BIT \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
49 (FLT_EXP_MASK < 0x100 ? 8 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
50 FLT_EXP_MASK < 0x200 ? 9 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
51 FLT_EXP_MASK < 0x400 ? 10 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
52 FLT_EXP_MASK < 0x800 ? 11 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
53 FLT_EXP_MASK < 0x1000 ? 12 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
54 FLT_EXP_MASK < 0x2000 ? 13 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
55 FLT_EXP_MASK < 0x4000 ? 14 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
56 FLT_EXP_MASK < 0x8000 ? 15 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
57 FLT_EXP_MASK < 0x10000 ? 16 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
58 FLT_EXP_MASK < 0x20000 ? 17 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
59 FLT_EXP_MASK < 0x40000 ? 18 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
60 FLT_EXP_MASK < 0x80000 ? 19 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
61 FLT_EXP_MASK < 0x100000 ? 20 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
62 FLT_EXP_MASK < 0x200000 ? 21 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
63 FLT_EXP_MASK < 0x400000 ? 22 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
64 FLT_EXP_MASK < 0x800000 ? 23 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
65 FLT_EXP_MASK < 0x1000000 ? 24 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
66 FLT_EXP_MASK < 0x2000000 ? 25 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
67 FLT_EXP_MASK < 0x4000000 ? 26 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
68 FLT_EXP_MASK < 0x8000000 ? 27 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
69 FLT_EXP_MASK < 0x10000000 ? 28 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
70 FLT_EXP_MASK < 0x20000000 ? 29 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
71 FLT_EXP_MASK < 0x40000000 ? 30 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
72 FLT_EXP_MASK <= 0x7fffffff ? 31 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
73 32)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
74 #define DBL_EXP_BIT \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
75 (DBL_EXP_MASK < 0x100 ? 8 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
76 DBL_EXP_MASK < 0x200 ? 9 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
77 DBL_EXP_MASK < 0x400 ? 10 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
78 DBL_EXP_MASK < 0x800 ? 11 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
79 DBL_EXP_MASK < 0x1000 ? 12 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
80 DBL_EXP_MASK < 0x2000 ? 13 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
81 DBL_EXP_MASK < 0x4000 ? 14 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
82 DBL_EXP_MASK < 0x8000 ? 15 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
83 DBL_EXP_MASK < 0x10000 ? 16 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
84 DBL_EXP_MASK < 0x20000 ? 17 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
85 DBL_EXP_MASK < 0x40000 ? 18 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
86 DBL_EXP_MASK < 0x80000 ? 19 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
87 DBL_EXP_MASK < 0x100000 ? 20 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
88 DBL_EXP_MASK < 0x200000 ? 21 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
89 DBL_EXP_MASK < 0x400000 ? 22 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
90 DBL_EXP_MASK < 0x800000 ? 23 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
91 DBL_EXP_MASK < 0x1000000 ? 24 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
92 DBL_EXP_MASK < 0x2000000 ? 25 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
93 DBL_EXP_MASK < 0x4000000 ? 26 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
94 DBL_EXP_MASK < 0x8000000 ? 27 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
95 DBL_EXP_MASK < 0x10000000 ? 28 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
96 DBL_EXP_MASK < 0x20000000 ? 29 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
97 DBL_EXP_MASK < 0x40000000 ? 30 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
98 DBL_EXP_MASK <= 0x7fffffff ? 31 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
99 32)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
100 #define LDBL_EXP_BIT \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
101 (LDBL_EXP_MASK < 0x100 ? 8 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
102 LDBL_EXP_MASK < 0x200 ? 9 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
103 LDBL_EXP_MASK < 0x400 ? 10 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
104 LDBL_EXP_MASK < 0x800 ? 11 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
105 LDBL_EXP_MASK < 0x1000 ? 12 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
106 LDBL_EXP_MASK < 0x2000 ? 13 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
107 LDBL_EXP_MASK < 0x4000 ? 14 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
108 LDBL_EXP_MASK < 0x8000 ? 15 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
109 LDBL_EXP_MASK < 0x10000 ? 16 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
110 LDBL_EXP_MASK < 0x20000 ? 17 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
111 LDBL_EXP_MASK < 0x40000 ? 18 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
112 LDBL_EXP_MASK < 0x80000 ? 19 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
113 LDBL_EXP_MASK < 0x100000 ? 20 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
114 LDBL_EXP_MASK < 0x200000 ? 21 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
115 LDBL_EXP_MASK < 0x400000 ? 22 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
116 LDBL_EXP_MASK < 0x800000 ? 23 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
117 LDBL_EXP_MASK < 0x1000000 ? 24 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
118 LDBL_EXP_MASK < 0x2000000 ? 25 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
119 LDBL_EXP_MASK < 0x4000000 ? 26 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
120 LDBL_EXP_MASK < 0x8000000 ? 27 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
121 LDBL_EXP_MASK < 0x10000000 ? 28 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
122 LDBL_EXP_MASK < 0x20000000 ? 29 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
123 LDBL_EXP_MASK < 0x40000000 ? 30 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
124 LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
125 32)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
126
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
127 /* Number of bits used for a floating-point number: the mantissa (not
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
128 counting the "hidden bit", since it may or may not be explicit), the
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
129 exponent, and the sign. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
130 #define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
131 #define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
132 #define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
133
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
134 /* Number of bytes used for a floating-point number.
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
135 This can be smaller than the 'sizeof'. For example, on i386 systems,
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
136 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
137 LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
138 sizeof (long double) = 12 or = 16. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
139 #define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
140 #define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
141 #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
142
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
143 /* Verify that SIZEOF_FLT <= sizeof (float) etc. */
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
144 typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1];
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
145 typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1];
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
146 typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1];
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
147
3c2e1f24cc7d Added generated files for release
lost@l-w.ca
parents:
diff changeset
148 #endif /* _FLOATPLUS_H */