Blame lib/float.in.h

Packit Service a2489d
/* A correct <float.h>.
Packit Service a2489d
Packit Service a2489d
   Copyright (C) 2007-2018 Free Software Foundation, Inc.
Packit Service a2489d
Packit Service a2489d
   This program is free software: you can redistribute it and/or modify
Packit Service a2489d
   it under the terms of the GNU General Public License as published by
Packit Service a2489d
   the Free Software Foundation; either version 3 of the License, or
Packit Service a2489d
   (at your option) any later version.
Packit Service a2489d
Packit Service a2489d
   This program is distributed in the hope that it will be useful,
Packit Service a2489d
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service a2489d
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service a2489d
   GNU General Public License for more details.
Packit Service a2489d
Packit Service a2489d
   You should have received a copy of the GNU General Public License
Packit Service a2489d
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service a2489d
Packit Service a2489d
#ifndef _@GUARD_PREFIX@_FLOAT_H
Packit Service a2489d
Packit Service a2489d
#if __GNUC__ >= 3
Packit Service a2489d
@PRAGMA_SYSTEM_HEADER@
Packit Service a2489d
#endif
Packit Service a2489d
@PRAGMA_COLUMNS@
Packit Service a2489d
Packit Service a2489d
/* The include_next requires a split double-inclusion guard.  */
Packit Service a2489d
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
Packit Service a2489d
Packit Service a2489d
#ifndef _@GUARD_PREFIX@_FLOAT_H
Packit Service a2489d
#define _@GUARD_PREFIX@_FLOAT_H
Packit Service a2489d
Packit Service a2489d
/* 'long double' properties.  */
Packit Service a2489d
Packit Service a2489d
#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
Packit Service a2489d
/* Number of mantissa units, in base FLT_RADIX.  */
Packit Service a2489d
# undef LDBL_MANT_DIG
Packit Service a2489d
# define LDBL_MANT_DIG   64
Packit Service a2489d
/* Number of decimal digits that is sufficient for representing a number.  */
Packit Service a2489d
# undef LDBL_DIG
Packit Service a2489d
# define LDBL_DIG        18
Packit Service a2489d
/* x-1 where x is the smallest representable number > 1.  */
Packit Service a2489d
# undef LDBL_EPSILON
Packit Service a2489d
# define LDBL_EPSILON    1.0842021724855044340E-19L
Packit Service a2489d
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */
Packit Service a2489d
# undef LDBL_MIN_EXP
Packit Service a2489d
# define LDBL_MIN_EXP    (-16381)
Packit Service a2489d
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */
Packit Service a2489d
# undef LDBL_MAX_EXP
Packit Service a2489d
# define LDBL_MAX_EXP    16384
Packit Service a2489d
/* Minimum positive normalized number.  */
Packit Service a2489d
# undef LDBL_MIN
Packit Service a2489d
# define LDBL_MIN        3.3621031431120935063E-4932L
Packit Service a2489d
/* Maximum representable finite number.  */
Packit Service a2489d
# undef LDBL_MAX
Packit Service a2489d
# define LDBL_MAX        1.1897314953572317650E+4932L
Packit Service a2489d
/* Minimum e such that 10^e is in the range of normalized numbers.  */
Packit Service a2489d
# undef LDBL_MIN_10_EXP
Packit Service a2489d
# define LDBL_MIN_10_EXP (-4931)
Packit Service a2489d
/* Maximum e such that 10^e is in the range of representable finite numbers.  */
Packit Service a2489d
# undef LDBL_MAX_10_EXP
Packit Service a2489d
# define LDBL_MAX_10_EXP 4932
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
Packit Service a2489d
   precision in the compiler but 64 bits of precision at runtime.  See
Packit Service a2489d
   <https://lists.gnu.org/r/bug-gnulib/2008-07/msg00063.html>.  */
Packit Service a2489d
#if defined __i386__ && (defined __FreeBSD__ || defined __DragonFly__)
Packit Service a2489d
/* Number of mantissa units, in base FLT_RADIX.  */
Packit Service a2489d
# undef LDBL_MANT_DIG
Packit Service a2489d
# define LDBL_MANT_DIG   64
Packit Service a2489d
/* Number of decimal digits that is sufficient for representing a number.  */
Packit Service a2489d
# undef LDBL_DIG
Packit Service a2489d
# define LDBL_DIG        18
Packit Service a2489d
/* x-1 where x is the smallest representable number > 1.  */
Packit Service a2489d
# undef LDBL_EPSILON
Packit Service a2489d
# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
Packit Service a2489d
/* Minimum e such that FLT_RADIX^(e-1) is a normalized number.  */
Packit Service a2489d
# undef LDBL_MIN_EXP
Packit Service a2489d
# define LDBL_MIN_EXP    (-16381)
Packit Service a2489d
/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number.  */
Packit Service a2489d
# undef LDBL_MAX_EXP
Packit Service a2489d
# define LDBL_MAX_EXP    16384
Packit Service a2489d
/* Minimum positive normalized number.  */
Packit Service a2489d
# undef LDBL_MIN
Packit Service a2489d
# define LDBL_MIN        3.362103143112093506262677817321752E-4932L /* = 0x1p-16382L */
Packit Service a2489d
/* Maximum representable finite number.  */
Packit Service a2489d
# undef LDBL_MAX
Packit Service a2489d
/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
Packit Service a2489d
   But the largest literal that GCC allows us to write is
Packit Service a2489d
   0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
Packit Service a2489d
   So, define it like this through a reference to an external variable
Packit Service a2489d
Packit Service a2489d
     const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
Packit Service a2489d
     extern const long double LDBL_MAX;
Packit Service a2489d
Packit Service a2489d
   Unfortunately, this is not a constant expression.  */
Packit Service a2489d
union gl_long_double_union
Packit Service a2489d
  {
Packit Service a2489d
    struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
Packit Service a2489d
    long double ld;
Packit Service a2489d
  };
Packit Service a2489d
extern const union gl_long_double_union gl_LDBL_MAX;
Packit Service a2489d
# define LDBL_MAX (gl_LDBL_MAX.ld)
Packit Service a2489d
/* Minimum e such that 10^e is in the range of normalized numbers.  */
Packit Service a2489d
# undef LDBL_MIN_10_EXP
Packit Service a2489d
# define LDBL_MIN_10_EXP (-4931)
Packit Service a2489d
/* Maximum e such that 10^e is in the range of representable finite numbers.  */
Packit Service a2489d
# undef LDBL_MAX_10_EXP
Packit Service a2489d
# define LDBL_MAX_10_EXP 4932
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
Packit Service a2489d
   wrong.
Packit Service a2489d
   On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong.  */
Packit Service a2489d
#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
Packit Service a2489d
# undef LDBL_MIN_EXP
Packit Service a2489d
# define LDBL_MIN_EXP DBL_MIN_EXP
Packit Service a2489d
# undef LDBL_MIN_10_EXP
Packit Service a2489d
# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
Packit Service a2489d
# undef LDBL_MIN
Packit Service a2489d
# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
Packit Service a2489d
#endif
Packit Service a2489d
#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
Packit Service a2489d
# undef LDBL_MAX
Packit Service a2489d
/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
Packit Service a2489d
   It is not easy to define:
Packit Service a2489d
     #define LDBL_MAX 1.79769313486231580793728971405302307166e308L
Packit Service a2489d
   is too small, whereas
Packit Service a2489d
     #define LDBL_MAX 1.79769313486231580793728971405302307167e308L
Packit Service a2489d
   is too large.  Apparently a bug in GCC decimal-to-binary conversion.
Packit Service a2489d
   Also, I can't get values larger than
Packit Service a2489d
     #define LDBL63 ((long double) (1ULL << 63))
Packit Service a2489d
     #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
Packit Service a2489d
     #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
Packit Service a2489d
     #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
Packit Service a2489d
     #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
Packit Service a2489d
   which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
Packit Service a2489d
   So, define it like this through a reference to an external variable
Packit Service a2489d
Packit Service a2489d
     const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
Packit Service a2489d
     extern const long double LDBL_MAX;
Packit Service a2489d
Packit Service a2489d
   or through a pointer cast
Packit Service a2489d
Packit Service a2489d
     #define LDBL_MAX \
Packit Service a2489d
       (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
Packit Service a2489d
Packit Service a2489d
   Unfortunately, this is not a constant expression, and the latter expression
Packit Service a2489d
   does not work well when GCC is optimizing..  */
Packit Service a2489d
union gl_long_double_union
Packit Service a2489d
  {
Packit Service a2489d
    struct { double hi; double lo; } dd;
Packit Service a2489d
    long double ld;
Packit Service a2489d
  };
Packit Service a2489d
extern const union gl_long_double_union gl_LDBL_MAX;
Packit Service a2489d
# define LDBL_MAX (gl_LDBL_MAX.ld)
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
Packit Service a2489d
   On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
Packit Service a2489d
   are wrong.  */
Packit Service a2489d
#if defined __sgi && (LDBL_MANT_DIG >= 106)
Packit Service a2489d
# undef LDBL_MANT_DIG
Packit Service a2489d
# define LDBL_MANT_DIG 106
Packit Service a2489d
# if defined __GNUC__
Packit Service a2489d
#  undef LDBL_MIN_EXP
Packit Service a2489d
#  define LDBL_MIN_EXP DBL_MIN_EXP
Packit Service a2489d
#  undef LDBL_MIN_10_EXP
Packit Service a2489d
#  define LDBL_MIN_10_EXP DBL_MIN_10_EXP
Packit Service a2489d
#  undef LDBL_MIN
Packit Service a2489d
#  define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
Packit Service a2489d
#  undef LDBL_EPSILON
Packit Service a2489d
#  define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
Packit Service a2489d
# endif
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
#if @REPLACE_ITOLD@
Packit Service a2489d
/* Pull in a function that fixes the 'int' to 'long double' conversion
Packit Service a2489d
   of glibc 2.7.  */
Packit Service a2489d
extern
Packit Service a2489d
# ifdef __cplusplus
Packit Service a2489d
"C"
Packit Service a2489d
# endif
Packit Service a2489d
void _Qp_itoq (long double *, int);
Packit Service a2489d
static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
#endif /* _@GUARD_PREFIX@_FLOAT_H */
Packit Service a2489d
#endif /* _@GUARD_PREFIX@_FLOAT_H */