annotate lib/float+.h @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8527
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Supplemental information about the floating-point formats.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
8527
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2007.
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 any later version.
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
8527
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 #ifndef _FLOATPLUS_H
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #define _FLOATPLUS_H
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <float.h>
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <limits.h>
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 /* Number of bits in the mantissa of a floating-point number, including the
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 "hidden bit". */
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #if FLT_RADIX == 2
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 # define FLT_MANT_BIT FLT_MANT_DIG
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 # define DBL_MANT_BIT DBL_MANT_DIG
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 # define LDBL_MANT_BIT LDBL_MANT_DIG
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #elif FLT_RADIX == 4
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 # define FLT_MANT_BIT (FLT_MANT_DIG * 2)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 # define DBL_MANT_BIT (DBL_MANT_DIG * 2)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 # define LDBL_MANT_BIT (LDBL_MANT_DIG * 2)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 #elif FLT_RADIX == 16
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 # define FLT_MANT_BIT (FLT_MANT_DIG * 4)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 # define DBL_MANT_BIT (DBL_MANT_DIG * 4)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 # define LDBL_MANT_BIT (LDBL_MANT_DIG * 4)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 #endif
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 /* Bit mask that can be used to mask the exponent, as an unsigned number. */
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 #define FLT_EXP_MASK ((FLT_MAX_EXP - FLT_MIN_EXP) | 7)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 #define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 #define LDBL_EXP_MASK ((LDBL_MAX_EXP - LDBL_MIN_EXP) | 7)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 /* Number of bits used for the exponent of a floating-point number, including
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 the exponent's sign. */
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 #define FLT_EXP_BIT \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 (FLT_EXP_MASK < 0x100 ? 8 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 FLT_EXP_MASK < 0x200 ? 9 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 FLT_EXP_MASK < 0x400 ? 10 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 FLT_EXP_MASK < 0x800 ? 11 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 FLT_EXP_MASK < 0x1000 ? 12 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 FLT_EXP_MASK < 0x2000 ? 13 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 FLT_EXP_MASK < 0x4000 ? 14 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 FLT_EXP_MASK < 0x8000 ? 15 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 FLT_EXP_MASK < 0x10000 ? 16 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 FLT_EXP_MASK < 0x20000 ? 17 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 FLT_EXP_MASK < 0x40000 ? 18 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 FLT_EXP_MASK < 0x80000 ? 19 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 FLT_EXP_MASK < 0x100000 ? 20 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 FLT_EXP_MASK < 0x200000 ? 21 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 FLT_EXP_MASK < 0x400000 ? 22 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 FLT_EXP_MASK < 0x800000 ? 23 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 FLT_EXP_MASK < 0x1000000 ? 24 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 FLT_EXP_MASK < 0x2000000 ? 25 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 FLT_EXP_MASK < 0x4000000 ? 26 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 FLT_EXP_MASK < 0x8000000 ? 27 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 FLT_EXP_MASK < 0x10000000 ? 28 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 FLT_EXP_MASK < 0x20000000 ? 29 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 FLT_EXP_MASK < 0x40000000 ? 30 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 FLT_EXP_MASK <= 0x7fffffff ? 31 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 32)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 #define DBL_EXP_BIT \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 (DBL_EXP_MASK < 0x100 ? 8 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 DBL_EXP_MASK < 0x200 ? 9 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 DBL_EXP_MASK < 0x400 ? 10 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 DBL_EXP_MASK < 0x800 ? 11 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 DBL_EXP_MASK < 0x1000 ? 12 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 DBL_EXP_MASK < 0x2000 ? 13 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 DBL_EXP_MASK < 0x4000 ? 14 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 DBL_EXP_MASK < 0x8000 ? 15 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 DBL_EXP_MASK < 0x10000 ? 16 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 DBL_EXP_MASK < 0x20000 ? 17 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 DBL_EXP_MASK < 0x40000 ? 18 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 DBL_EXP_MASK < 0x80000 ? 19 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 DBL_EXP_MASK < 0x100000 ? 20 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 DBL_EXP_MASK < 0x200000 ? 21 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 DBL_EXP_MASK < 0x400000 ? 22 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 DBL_EXP_MASK < 0x800000 ? 23 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 DBL_EXP_MASK < 0x1000000 ? 24 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 DBL_EXP_MASK < 0x2000000 ? 25 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 DBL_EXP_MASK < 0x4000000 ? 26 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 DBL_EXP_MASK < 0x8000000 ? 27 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 DBL_EXP_MASK < 0x10000000 ? 28 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 DBL_EXP_MASK < 0x20000000 ? 29 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 DBL_EXP_MASK < 0x40000000 ? 30 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 DBL_EXP_MASK <= 0x7fffffff ? 31 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 32)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 #define LDBL_EXP_BIT \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 (LDBL_EXP_MASK < 0x100 ? 8 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 LDBL_EXP_MASK < 0x200 ? 9 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 LDBL_EXP_MASK < 0x400 ? 10 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 LDBL_EXP_MASK < 0x800 ? 11 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 LDBL_EXP_MASK < 0x1000 ? 12 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 LDBL_EXP_MASK < 0x2000 ? 13 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 LDBL_EXP_MASK < 0x4000 ? 14 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 LDBL_EXP_MASK < 0x8000 ? 15 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 LDBL_EXP_MASK < 0x10000 ? 16 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 LDBL_EXP_MASK < 0x20000 ? 17 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 LDBL_EXP_MASK < 0x40000 ? 18 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 LDBL_EXP_MASK < 0x80000 ? 19 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 LDBL_EXP_MASK < 0x100000 ? 20 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 LDBL_EXP_MASK < 0x200000 ? 21 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 LDBL_EXP_MASK < 0x400000 ? 22 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 LDBL_EXP_MASK < 0x800000 ? 23 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 LDBL_EXP_MASK < 0x1000000 ? 24 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 LDBL_EXP_MASK < 0x2000000 ? 25 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 LDBL_EXP_MASK < 0x4000000 ? 26 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 LDBL_EXP_MASK < 0x8000000 ? 27 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 LDBL_EXP_MASK < 0x10000000 ? 28 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 LDBL_EXP_MASK < 0x20000000 ? 29 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 LDBL_EXP_MASK < 0x40000000 ? 30 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 LDBL_EXP_MASK <= 0x7fffffff ? 31 : \
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 32)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 /* Number of bits used for a floating-point number: the mantissa (not
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 counting the "hidden bit", since it may or may not be explicit), the
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 exponent, and the sign. */
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 #define FLT_TOTAL_BIT ((FLT_MANT_BIT - 1) + FLT_EXP_BIT + 1)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 #define DBL_TOTAL_BIT ((DBL_MANT_BIT - 1) + DBL_EXP_BIT + 1)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 #define LDBL_TOTAL_BIT ((LDBL_MANT_BIT - 1) + LDBL_EXP_BIT + 1)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 /* Number of bytes used for a floating-point number.
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 This can be smaller than the 'sizeof'. For example, on i386 systems,
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 'long double' most often have LDBL_MANT_BIT = 64, LDBL_EXP_BIT = 16, hence
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 LDBL_TOTAL_BIT = 80 bits, i.e. 10 bytes of consecutive memory, but
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 sizeof (long double) = 12 or = 16. */
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 #define SIZEOF_FLT ((FLT_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 #define SIZEOF_DBL ((DBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 /* Verify that SIZEOF_FLT <= sizeof (float) etc. */
13788
6f8ee3f6161c rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1]
Paul Eggert <eggert@cs.ucla.edu>
parents: 12559
diff changeset
143 typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
6f8ee3f6161c rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1]
Paul Eggert <eggert@cs.ucla.edu>
parents: 12559
diff changeset
144 typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
6f8ee3f6161c rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1]
Paul Eggert <eggert@cs.ucla.edu>
parents: 12559
diff changeset
145 typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
8527
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146
7e5222add641 Support for bitwise comparison of floating-point numbers.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 #endif /* _FLOATPLUS_H */