3 ?RCS: Copyright (c) 2015 Jarkko Hietaniemi, H.Merijn Brand
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
8 ?MAKE:longdblmantbits doublemantbits nvmantbits: Inlibc cat Compile run \
9 rm_try Setvar echo i_sunmath usequadmath \
10 d_longdbl longdblkind nvsize doublesize longdblsize
11 ?MAKE: -pick add $@ %<
13 ?S: This symbol, if defined, tells how many mantissa bits
14 ?S: there are in double precision floating point format.
15 ?S: Note that this is usually DBL_MANT_DIG minus one, since
16 ?S: with the standard IEEE 754 formats DBL_MANT_DIG includes
17 ?S: the implicit bit which doesn't really exist.
20 ?S: This symbol, if defined, tells how many mantissa bits
21 ?S: there are in long double precision floating point format.
22 ?S: Note that this can be LDBL_MANT_DIG minus one,
23 ?S: since LDBL_MANT_DIG can include the IEEE 754 implicit bit.
24 ?S: The common x86-style 80-bit long double does not have
28 ?S: This variable tells how many bits the mantissa of a Perl NV has,
29 ?S: not including the possible implicit bit.
32 ?C: This symbol, if defined, tells how many mantissa bits
33 ?C: there are in double precision floating point format.
34 ?C: Note that this is usually DBL_MANT_DIG minus one, since
35 ?C: with the standard IEEE 754 formats DBL_MANT_DIG includes
36 ?C: the implicit bit, which doesn't really exist.
39 ?C: This symbol, if defined, tells how many mantissa bits
40 ?C: there are in long double precision floating point format.
41 ?C: Note that this can be LDBL_MANT_DIG minus one,
42 ?C: since LDBL_MANT_DIG can include the IEEE 754 implicit bit.
43 ?C: The common x86-style 80-bit long double does not have
47 ?C: This symbol, if defined, tells how many mantissa bits
48 ?C: (not including implicit bit) there are in a Perl NV.
49 ?C: This depends on which floating point type was chosen.
51 ?H:#define DOUBLEMANTBITS $doublemantbits
52 ?H:#define LONGDBLMANTBITS $longdblmantbits
53 ?H:#define NVMANTBITS $nvmantbits
56 : Check the length of the double mantissa
57 $echo "Checking how many mantissa bits your doubles have..." >&4
65 # define BITS (DBL_MANT_DIG - 1) /* the implicit bit does not count */
68 int main(int argc, char *argv[]) {
76 if eval $compile; then
77 doublemantbits=`$run ./try`
79 doublemantbits="$undef"
83 : Check the length of the longdouble mantissa
84 $echo "Checking how many mantissa bits your long doubles have..." >&4
91 #$d_longdbl HAS_LONG_DOUBLE
92 #if defined(HAS_LONG_DOUBLE) && defined(LDBL_MANT_DIG)
93 # if ($longdblkind == 3) || ($longdblkind == 4) /* 80-bit extended precision */
94 /* This format has no implicit bit. Beware, however, that for
95 * this format the bare LDBL_MANT_DIG is misleading for inf/nan:
96 * the top three bits are used for inf (100) / qnan (11x) / snan (101),
97 * and the top bit must have been one since 387, zero is plain invalid.
98 * For normal fp values, the LDBL_MANT_DIG is fine, though. */
99 # define BITS LDBL_MANT_DIG
100 # elif ($longdblkind == 5 || $longdblkind == 6 || $longdblkind == 7 || $longdblkind == 8) /* double double */
101 /* LDBL_MANT_DIG of 106 (twice 53) would be logical, but for some
102 * reason e.g. Irix thinks 107. But in any case, we want only
103 * the number of real bits, the implicit bits are of no interest. */
104 # define BITS 2 * (DBL_MANT_DIG - 1)
106 # define BITS (LDBL_MANT_DIG - 1) /* the implicit bit does not count */
110 int main(int argc, char *argv[]) {
112 printf("%d\n", BITS);
118 if eval $compile; then
119 longdblmantbits=`$run ./try`
121 longdblmantbits="$undef"
125 : Check the length of the NV mantissa
126 $echo "Checking how many mantissa bits your NVs have..." >&4
127 if test "X$usequadmath" = "X$define"; then
128 nvmantbits=112 # 128-1-15
130 if test "X$nvsize" = "X$doublesize"; then
131 nvmantbits="$doublemantbits"
133 if test "X$nvsize" = "X$longdblsize"; then
134 nvmantbits="$longdblmantbits"