Update copyright notices with scripts/update-copyrights
[jlayton/glibc.git] / misc / qefgcvt.c
1 /* Compatibility functions for floating point formatting, long double version.
2    Copyright (C) 1996-2014 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #include <float.h>
20
21 #define FLOAT_TYPE long double
22 #define FUNC_PREFIX q
23 #define FLOAT_FMT_FLAG "L"
24 /* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
25    we don't have log10 available in the preprocessor.  Since we cannot
26    assume anything on the used `long double' format be generous.  */
27 #define MAXDIG (NDIGIT_MAX + 12)
28 #define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
29 #if LDBL_MANT_DIG == 64
30 # define NDIGIT_MAX 21
31 #elif LDBL_MANT_DIG == 53
32 # define NDIGIT_MAX 17
33 #elif LDBL_MANT_DIG == 113
34 # define NDIGIT_MAX 36
35 #elif LDBL_MANT_DIG == 106
36 # define NDIGIT_MAX 34
37 #elif LDBL_MANT_DIG == 56
38 # define NDIGIT_MAX 18
39 #else
40 /* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
41    compile time constant here, so we cannot use it.  */
42 # error "NDIGIT_MAX must be precomputed"
43 # define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
44 #endif
45
46 #include "efgcvt.c"