beta-0.89.2
[luatex.git] / source / libs / mpfr / mpfr-3.1.3 / src / ieee_floats.h
blob0cb44926adaeb5f33c3ac5379c6ff25487bc6dba
1 /* auxiliary data to generate special IEEE floats (NaN, +Inf, -Inf)
3 Copyright 1999-2015 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel projects, INRIA.
6 This file is part of the GNU MPFR Library.
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
20 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
23 /* "double" NaN and infinities are written as explicit bytes to be sure of
24 getting what we want, and to be sure of not depending on libm.
26 Could use 4-byte "float" values and let the code convert them, but it
27 seems more direct to give exactly what we want. Certainly for gcc 3.0.2
28 on alphaev56-unknown-freebsd4.3 the NaN must be 8-bytes, since that
29 compiler+system was seen incorrectly converting from a "float" NaN. */
31 #if _GMP_IEEE_FLOATS
33 /* The "d" field guarantees alignment to a suitable boundary for a double.
34 Could use a union instead, if we checked the compiler supports union
35 initializers. */
36 union dbl_bytes {
37 unsigned char b[8];
38 double d;
41 #define MPFR_DBL_INFP (dbl_infp.d)
42 #define MPFR_DBL_INFM (dbl_infm.d)
43 #define MPFR_DBL_NAN (dbl_nan.d)
45 /* Warning! dbl_nan.d is not consistently the same NaN on all the
46 processors: it can be either a qNaN (quiet) or sNaN (signaling).
47 Processors are known to differ... */
49 #if HAVE_DOUBLE_IEEE_LITTLE_ENDIAN
50 static const union dbl_bytes dbl_infp =
51 { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } };
52 static const union dbl_bytes dbl_infm =
53 { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } };
54 static const union dbl_bytes dbl_nan =
55 { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } };
56 #endif
57 #if HAVE_DOUBLE_IEEE_LITTLE_SWAPPED
58 static const union dbl_bytes dbl_infp =
59 { { 0, 0, 0xF0, 0x7F, 0, 0, 0, 0 } };
60 static const union dbl_bytes dbl_infm =
61 { { 0, 0, 0xF0, 0xFF, 0, 0, 0, 0 } };
62 static const union dbl_bytes dbl_nan =
63 { { 0, 0, 0xF8, 0x7F, 0, 0, 0, 0 } };
64 #endif
65 #if HAVE_DOUBLE_IEEE_BIG_ENDIAN
66 static const union dbl_bytes dbl_infp =
67 { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } };
68 static const union dbl_bytes dbl_infm =
69 { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } };
70 static const union dbl_bytes dbl_nan =
71 { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } };
72 #endif
74 #else /* _GMP_IEEE_FLOATS */
76 #define MPFR_DBL_INFP DBL_POS_INF
77 #define MPFR_DBL_INFM DBL_NEG_INF
78 #define MPFR_DBL_NAN DBL_NAN
80 #endif /* _GMP_IEEE_FLOATS */