1/* auxiliary data to generate special IEEE floats (NaN, +Inf, -Inf) 2 3Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. 4Contributed by the AriC and Caramel projects, INRIA. 5 6This file is part of the GNU MPFR Library. 7 8The GNU MPFR Library is free software; you can redistribute it and/or modify 9it under the terms of the GNU Lesser General Public License as published by 10the Free Software Foundation; either version 3 of the License, or (at your 11option) any later version. 12 13The GNU MPFR Library is distributed in the hope that it will be useful, but 14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16License for more details. 17 18You should have received a copy of the GNU Lesser General Public License 19along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see 20http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 2151 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ 22 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. 25 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. */ 30 31#if _GMP_IEEE_FLOATS 32 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. */ 36union dbl_bytes { 37 unsigned char b[8]; 38 double d; 39}; 40 41#define MPFR_DBL_INFP (dbl_infp.d) 42#define MPFR_DBL_INFM (dbl_infm.d) 43#define MPFR_DBL_NAN (dbl_nan.d) 44 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... */ 48 49#if HAVE_DOUBLE_IEEE_LITTLE_ENDIAN 50static const union dbl_bytes dbl_infp = 51 { { 0, 0, 0, 0, 0, 0, 0xF0, 0x7F } }; 52static const union dbl_bytes dbl_infm = 53 { { 0, 0, 0, 0, 0, 0, 0xF0, 0xFF } }; 54static const union dbl_bytes dbl_nan = 55 { { 0, 0, 0, 0, 0, 0, 0xF8, 0x7F } }; 56#endif 57#if HAVE_DOUBLE_IEEE_LITTLE_SWAPPED 58static const union dbl_bytes dbl_infp = 59 { { 0, 0, 0xF0, 0x7F, 0, 0, 0, 0 } }; 60static const union dbl_bytes dbl_infm = 61 { { 0, 0, 0xF0, 0xFF, 0, 0, 0, 0 } }; 62static const union dbl_bytes dbl_nan = 63 { { 0, 0, 0xF8, 0x7F, 0, 0, 0, 0 } }; 64#endif 65#if HAVE_DOUBLE_IEEE_BIG_ENDIAN 66static const union dbl_bytes dbl_infp = 67 { { 0x7F, 0xF0, 0, 0, 0, 0, 0, 0 } }; 68static const union dbl_bytes dbl_infm = 69 { { 0xFF, 0xF0, 0, 0, 0, 0, 0, 0 } }; 70static const union dbl_bytes dbl_nan = 71 { { 0x7F, 0xF8, 0, 0, 0, 0, 0, 0 } }; 72#endif 73 74#else /* _GMP_IEEE_FLOATS */ 75 76#define MPFR_DBL_INFP DBL_POS_INF 77#define MPFR_DBL_INFM DBL_NEG_INF 78#define MPFR_DBL_NAN DBL_NAN 79 80#endif /* _GMP_IEEE_FLOATS */ 81