Update copyright notices with scripts/update-copyrights
[glibc.git] / stdlib / fpioconst.h
blob66c4936a915475b33c52639b67d59a19405e5ca0
1 /* Header file for constants used in floating point <-> decimal conversions.
2 Copyright (C) 1995-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #ifndef _FPIOCONST_H
20 #define _FPIOCONST_H
22 #include <float.h>
23 #include <math.h>
24 #include <gmp.h>
27 /* These values are used by __printf_fp, where they are noncritical (if the
28 value is not large enough, it will just be slower); and by
29 strtof/strtod/strtold, where it is critical (it's used for overflow
30 detection).
32 XXX These should be defined in <float.h>. For the time being, we have the
33 IEEE754 values here. */
35 #if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
36 # define LDBL_MAX_10_EXP_LOG 12 /* = floor(log_2(LDBL_MAX_10_EXP)) */
37 #else
38 # define LDBL_MAX_10_EXP_LOG 8 /* = floor(log_2(LDBL_MAX_10_EXP)) */
39 #endif
40 #define DBL_MAX_10_EXP_LOG 8 /* = floor(log_2(DBL_MAX_10_EXP)) */
41 #define FLT_MAX_10_EXP_LOG 5 /* = floor(log_2(FLT_MAX_10_EXP)) */
43 /* For strtold, we need powers of 10 up to floor (log_2 (LDBL_MANT_DIG
44 - LDBL_MIN_EXP + 2)). */
45 #if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
46 # define FPIOCONST_POW10_ARRAY_SIZE 15
47 #else
48 # define FPIOCONST_POW10_ARRAY_SIZE 11
49 #endif
51 /* The array with the number representation. */
52 extern const mp_limb_t __tens[] attribute_hidden;
54 /* Table of powers of ten. This is used by __printf_fp and by
55 strtof/strtod/strtold. */
56 struct mp_power
58 size_t arrayoff; /* Offset in `__tens'. */
59 mp_size_t arraysize; /* Size of the array. */
60 int p_expo; /* Exponent of the number 10^(2^i). */
61 int m_expo; /* Exponent of the number 10^-(2^i-1). */
63 extern const struct mp_power _fpioconst_pow10[FPIOCONST_POW10_ARRAY_SIZE]
64 attribute_hidden;
66 /* The constants in the array `_fpioconst_pow10' have an offset. */
67 #if BITS_PER_MP_LIMB == 32
68 # define _FPIO_CONST_OFFSET 2
69 #else
70 # define _FPIO_CONST_OFFSET 1
71 #endif
74 #endif /* fpioconst.h */