1*e4b17023SJohn Marino /* Copyright (C) 2002, 2007, 2008, 2009, 2010, 2011 2*e4b17023SJohn Marino Free Software Foundation, Inc. 3*e4b17023SJohn Marino 4*e4b17023SJohn Marino This file is part of GCC. 5*e4b17023SJohn Marino 6*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify 7*e4b17023SJohn Marino it under the terms of the GNU General Public License as published by 8*e4b17023SJohn Marino the Free Software Foundation; either version 3, or (at your option) 9*e4b17023SJohn Marino any later version. 10*e4b17023SJohn Marino 11*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, 12*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 13*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*e4b17023SJohn Marino GNU General Public License for more details. 15*e4b17023SJohn Marino 16*e4b17023SJohn Marino Under Section 7 of GPL version 3, you are granted additional 17*e4b17023SJohn Marino permissions described in the GCC Runtime Library Exception, version 18*e4b17023SJohn Marino 3.1, as published by the Free Software Foundation. 19*e4b17023SJohn Marino 20*e4b17023SJohn Marino You should have received a copy of the GNU General Public License and 21*e4b17023SJohn Marino a copy of the GCC Runtime Library Exception along with this program; 22*e4b17023SJohn Marino see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 24*e4b17023SJohn Marino 25*e4b17023SJohn Marino /* 26*e4b17023SJohn Marino * ISO C Standard: 5.2.4.2.2 Characteristics of floating types <float.h> 27*e4b17023SJohn Marino */ 28*e4b17023SJohn Marino 29*e4b17023SJohn Marino #ifndef _FLOAT_H___ 30*e4b17023SJohn Marino #define _FLOAT_H___ 31*e4b17023SJohn Marino 32*e4b17023SJohn Marino /* Radix of exponent representation, b. */ 33*e4b17023SJohn Marino #undef FLT_RADIX 34*e4b17023SJohn Marino #define FLT_RADIX __FLT_RADIX__ 35*e4b17023SJohn Marino 36*e4b17023SJohn Marino /* Number of base-FLT_RADIX digits in the significand, p. */ 37*e4b17023SJohn Marino #undef FLT_MANT_DIG 38*e4b17023SJohn Marino #undef DBL_MANT_DIG 39*e4b17023SJohn Marino #undef LDBL_MANT_DIG 40*e4b17023SJohn Marino #define FLT_MANT_DIG __FLT_MANT_DIG__ 41*e4b17023SJohn Marino #define DBL_MANT_DIG __DBL_MANT_DIG__ 42*e4b17023SJohn Marino #define LDBL_MANT_DIG __LDBL_MANT_DIG__ 43*e4b17023SJohn Marino 44*e4b17023SJohn Marino /* Number of decimal digits, q, such that any floating-point number with q 45*e4b17023SJohn Marino decimal digits can be rounded into a floating-point number with p radix b 46*e4b17023SJohn Marino digits and back again without change to the q decimal digits, 47*e4b17023SJohn Marino 48*e4b17023SJohn Marino p * log10(b) if b is a power of 10 49*e4b17023SJohn Marino floor((p - 1) * log10(b)) otherwise 50*e4b17023SJohn Marino */ 51*e4b17023SJohn Marino #undef FLT_DIG 52*e4b17023SJohn Marino #undef DBL_DIG 53*e4b17023SJohn Marino #undef LDBL_DIG 54*e4b17023SJohn Marino #define FLT_DIG __FLT_DIG__ 55*e4b17023SJohn Marino #define DBL_DIG __DBL_DIG__ 56*e4b17023SJohn Marino #define LDBL_DIG __LDBL_DIG__ 57*e4b17023SJohn Marino 58*e4b17023SJohn Marino /* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */ 59*e4b17023SJohn Marino #undef FLT_MIN_EXP 60*e4b17023SJohn Marino #undef DBL_MIN_EXP 61*e4b17023SJohn Marino #undef LDBL_MIN_EXP 62*e4b17023SJohn Marino #define FLT_MIN_EXP __FLT_MIN_EXP__ 63*e4b17023SJohn Marino #define DBL_MIN_EXP __DBL_MIN_EXP__ 64*e4b17023SJohn Marino #define LDBL_MIN_EXP __LDBL_MIN_EXP__ 65*e4b17023SJohn Marino 66*e4b17023SJohn Marino /* Minimum negative integer such that 10 raised to that power is in the 67*e4b17023SJohn Marino range of normalized floating-point numbers, 68*e4b17023SJohn Marino 69*e4b17023SJohn Marino ceil(log10(b) * (emin - 1)) 70*e4b17023SJohn Marino */ 71*e4b17023SJohn Marino #undef FLT_MIN_10_EXP 72*e4b17023SJohn Marino #undef DBL_MIN_10_EXP 73*e4b17023SJohn Marino #undef LDBL_MIN_10_EXP 74*e4b17023SJohn Marino #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ 75*e4b17023SJohn Marino #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ 76*e4b17023SJohn Marino #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ 77*e4b17023SJohn Marino 78*e4b17023SJohn Marino /* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax. */ 79*e4b17023SJohn Marino #undef FLT_MAX_EXP 80*e4b17023SJohn Marino #undef DBL_MAX_EXP 81*e4b17023SJohn Marino #undef LDBL_MAX_EXP 82*e4b17023SJohn Marino #define FLT_MAX_EXP __FLT_MAX_EXP__ 83*e4b17023SJohn Marino #define DBL_MAX_EXP __DBL_MAX_EXP__ 84*e4b17023SJohn Marino #define LDBL_MAX_EXP __LDBL_MAX_EXP__ 85*e4b17023SJohn Marino 86*e4b17023SJohn Marino /* Maximum integer such that 10 raised to that power is in the range of 87*e4b17023SJohn Marino representable finite floating-point numbers, 88*e4b17023SJohn Marino 89*e4b17023SJohn Marino floor(log10((1 - b**-p) * b**emax)) 90*e4b17023SJohn Marino */ 91*e4b17023SJohn Marino #undef FLT_MAX_10_EXP 92*e4b17023SJohn Marino #undef DBL_MAX_10_EXP 93*e4b17023SJohn Marino #undef LDBL_MAX_10_EXP 94*e4b17023SJohn Marino #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ 95*e4b17023SJohn Marino #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ 96*e4b17023SJohn Marino #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ 97*e4b17023SJohn Marino 98*e4b17023SJohn Marino /* Maximum representable finite floating-point number, 99*e4b17023SJohn Marino 100*e4b17023SJohn Marino (1 - b**-p) * b**emax 101*e4b17023SJohn Marino */ 102*e4b17023SJohn Marino #undef FLT_MAX 103*e4b17023SJohn Marino #undef DBL_MAX 104*e4b17023SJohn Marino #undef LDBL_MAX 105*e4b17023SJohn Marino #define FLT_MAX __FLT_MAX__ 106*e4b17023SJohn Marino #define DBL_MAX __DBL_MAX__ 107*e4b17023SJohn Marino #define LDBL_MAX __LDBL_MAX__ 108*e4b17023SJohn Marino 109*e4b17023SJohn Marino /* The difference between 1 and the least value greater than 1 that is 110*e4b17023SJohn Marino representable in the given floating point type, b**1-p. */ 111*e4b17023SJohn Marino #undef FLT_EPSILON 112*e4b17023SJohn Marino #undef DBL_EPSILON 113*e4b17023SJohn Marino #undef LDBL_EPSILON 114*e4b17023SJohn Marino #define FLT_EPSILON __FLT_EPSILON__ 115*e4b17023SJohn Marino #define DBL_EPSILON __DBL_EPSILON__ 116*e4b17023SJohn Marino #define LDBL_EPSILON __LDBL_EPSILON__ 117*e4b17023SJohn Marino 118*e4b17023SJohn Marino /* Minimum normalized positive floating-point number, b**(emin - 1). */ 119*e4b17023SJohn Marino #undef FLT_MIN 120*e4b17023SJohn Marino #undef DBL_MIN 121*e4b17023SJohn Marino #undef LDBL_MIN 122*e4b17023SJohn Marino #define FLT_MIN __FLT_MIN__ 123*e4b17023SJohn Marino #define DBL_MIN __DBL_MIN__ 124*e4b17023SJohn Marino #define LDBL_MIN __LDBL_MIN__ 125*e4b17023SJohn Marino 126*e4b17023SJohn Marino /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown. */ 127*e4b17023SJohn Marino /* ??? This is supposed to change with calls to fesetround in <fenv.h>. */ 128*e4b17023SJohn Marino #undef FLT_ROUNDS 129*e4b17023SJohn Marino #define FLT_ROUNDS 1 130*e4b17023SJohn Marino 131*e4b17023SJohn Marino #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 132*e4b17023SJohn Marino /* The floating-point expression evaluation method. 133*e4b17023SJohn Marino -1 indeterminate 134*e4b17023SJohn Marino 0 evaluate all operations and constants just to the range and 135*e4b17023SJohn Marino precision of the type 136*e4b17023SJohn Marino 1 evaluate operations and constants of type float and double 137*e4b17023SJohn Marino to the range and precision of the double type, evaluate 138*e4b17023SJohn Marino long double operations and constants to the range and 139*e4b17023SJohn Marino precision of the long double type 140*e4b17023SJohn Marino 2 evaluate all operations and constants to the range and 141*e4b17023SJohn Marino precision of the long double type 142*e4b17023SJohn Marino 143*e4b17023SJohn Marino ??? This ought to change with the setting of the fp control word; 144*e4b17023SJohn Marino the value provided by the compiler assumes the widest setting. */ 145*e4b17023SJohn Marino #undef FLT_EVAL_METHOD 146*e4b17023SJohn Marino #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ 147*e4b17023SJohn Marino 148*e4b17023SJohn Marino /* Number of decimal digits, n, such that any floating-point number in the 149*e4b17023SJohn Marino widest supported floating type with pmax radix b digits can be rounded 150*e4b17023SJohn Marino to a floating-point number with n decimal digits and back again without 151*e4b17023SJohn Marino change to the value, 152*e4b17023SJohn Marino 153*e4b17023SJohn Marino pmax * log10(b) if b is a power of 10 154*e4b17023SJohn Marino ceil(1 + pmax * log10(b)) otherwise 155*e4b17023SJohn Marino */ 156*e4b17023SJohn Marino #undef DECIMAL_DIG 157*e4b17023SJohn Marino #define DECIMAL_DIG __DECIMAL_DIG__ 158*e4b17023SJohn Marino 159*e4b17023SJohn Marino #endif /* C99 */ 160*e4b17023SJohn Marino 161*e4b17023SJohn Marino #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 162*e4b17023SJohn Marino /* Versions of DECIMAL_DIG for each floating-point type. */ 163*e4b17023SJohn Marino #undef FLT_DECIMAL_DIG 164*e4b17023SJohn Marino #undef DBL_DECIMAL_DIG 165*e4b17023SJohn Marino #undef LDBL_DECIMAL_DIG 166*e4b17023SJohn Marino #define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ 167*e4b17023SJohn Marino #define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ 168*e4b17023SJohn Marino #define LDBL_DECIMAL_DIG __DECIMAL_DIG__ 169*e4b17023SJohn Marino 170*e4b17023SJohn Marino /* Whether types support subnormal numbers. */ 171*e4b17023SJohn Marino #undef FLT_HAS_SUBNORM 172*e4b17023SJohn Marino #undef DBL_HAS_SUBNORM 173*e4b17023SJohn Marino #undef LDBL_HAS_SUBNORM 174*e4b17023SJohn Marino #define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ 175*e4b17023SJohn Marino #define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ 176*e4b17023SJohn Marino #define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ 177*e4b17023SJohn Marino 178*e4b17023SJohn Marino /* Minimum positive values, including subnormals. */ 179*e4b17023SJohn Marino #undef FLT_TRUE_MIN 180*e4b17023SJohn Marino #undef DBL_TRUE_MIN 181*e4b17023SJohn Marino #undef LDBL_TRUE_MIN 182*e4b17023SJohn Marino #if __FLT_HAS_DENORM__ 183*e4b17023SJohn Marino #define FLT_TRUE_MIN __FLT_DENORM_MIN__ 184*e4b17023SJohn Marino #else 185*e4b17023SJohn Marino #define FLT_TRUE_MIN __FLT_MIN__ 186*e4b17023SJohn Marino #endif 187*e4b17023SJohn Marino #if __DBL_HAS_DENORM__ 188*e4b17023SJohn Marino #define DBL_TRUE_MIN __DBL_DENORM_MIN__ 189*e4b17023SJohn Marino #else 190*e4b17023SJohn Marino #define DBL_TRUE_MIN __DBL_MIN__ 191*e4b17023SJohn Marino #endif 192*e4b17023SJohn Marino #if __LDBL_HAS_DENORM__ 193*e4b17023SJohn Marino #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ 194*e4b17023SJohn Marino #else 195*e4b17023SJohn Marino #define LDBL_TRUE_MIN __LDBL_MIN__ 196*e4b17023SJohn Marino #endif 197*e4b17023SJohn Marino 198*e4b17023SJohn Marino #endif /* C11 */ 199*e4b17023SJohn Marino 200*e4b17023SJohn Marino #ifdef __STDC_WANT_DEC_FP__ 201*e4b17023SJohn Marino /* Draft Technical Report 24732, extension for decimal floating-point 202*e4b17023SJohn Marino arithmetic: Characteristic of decimal floating types <float.h>. */ 203*e4b17023SJohn Marino 204*e4b17023SJohn Marino /* Number of base-FLT_RADIX digits in the significand, p. */ 205*e4b17023SJohn Marino #undef DEC32_MANT_DIG 206*e4b17023SJohn Marino #undef DEC64_MANT_DIG 207*e4b17023SJohn Marino #undef DEC128_MANT_DIG 208*e4b17023SJohn Marino #define DEC32_MANT_DIG __DEC32_MANT_DIG__ 209*e4b17023SJohn Marino #define DEC64_MANT_DIG __DEC64_MANT_DIG__ 210*e4b17023SJohn Marino #define DEC128_MANT_DIG __DEC128_MANT_DIG__ 211*e4b17023SJohn Marino 212*e4b17023SJohn Marino /* Minimum exponent. */ 213*e4b17023SJohn Marino #undef DEC32_MIN_EXP 214*e4b17023SJohn Marino #undef DEC64_MIN_EXP 215*e4b17023SJohn Marino #undef DEC128_MIN_EXP 216*e4b17023SJohn Marino #define DEC32_MIN_EXP __DEC32_MIN_EXP__ 217*e4b17023SJohn Marino #define DEC64_MIN_EXP __DEC64_MIN_EXP__ 218*e4b17023SJohn Marino #define DEC128_MIN_EXP __DEC128_MIN_EXP__ 219*e4b17023SJohn Marino 220*e4b17023SJohn Marino /* Maximum exponent. */ 221*e4b17023SJohn Marino #undef DEC32_MAX_EXP 222*e4b17023SJohn Marino #undef DEC64_MAX_EXP 223*e4b17023SJohn Marino #undef DEC128_MAX_EXP 224*e4b17023SJohn Marino #define DEC32_MAX_EXP __DEC32_MAX_EXP__ 225*e4b17023SJohn Marino #define DEC64_MAX_EXP __DEC64_MAX_EXP__ 226*e4b17023SJohn Marino #define DEC128_MAX_EXP __DEC128_MAX_EXP__ 227*e4b17023SJohn Marino 228*e4b17023SJohn Marino /* Maximum representable finite decimal floating-point number 229*e4b17023SJohn Marino (there are 6, 15, and 33 9s after the decimal points respectively). */ 230*e4b17023SJohn Marino #undef DEC32_MAX 231*e4b17023SJohn Marino #undef DEC64_MAX 232*e4b17023SJohn Marino #undef DEC128_MAX 233*e4b17023SJohn Marino #define DEC32_MAX __DEC32_MAX__ 234*e4b17023SJohn Marino #define DEC64_MAX __DEC64_MAX__ 235*e4b17023SJohn Marino #define DEC128_MAX __DEC128_MAX__ 236*e4b17023SJohn Marino 237*e4b17023SJohn Marino /* The difference between 1 and the least value greater than 1 that is 238*e4b17023SJohn Marino representable in the given floating point type. */ 239*e4b17023SJohn Marino #undef DEC32_EPSILON 240*e4b17023SJohn Marino #undef DEC64_EPSILON 241*e4b17023SJohn Marino #undef DEC128_EPSILON 242*e4b17023SJohn Marino #define DEC32_EPSILON __DEC32_EPSILON__ 243*e4b17023SJohn Marino #define DEC64_EPSILON __DEC64_EPSILON__ 244*e4b17023SJohn Marino #define DEC128_EPSILON __DEC128_EPSILON__ 245*e4b17023SJohn Marino 246*e4b17023SJohn Marino /* Minimum normalized positive floating-point number. */ 247*e4b17023SJohn Marino #undef DEC32_MIN 248*e4b17023SJohn Marino #undef DEC64_MIN 249*e4b17023SJohn Marino #undef DEC128_MIN 250*e4b17023SJohn Marino #define DEC32_MIN __DEC32_MIN__ 251*e4b17023SJohn Marino #define DEC64_MIN __DEC64_MIN__ 252*e4b17023SJohn Marino #define DEC128_MIN __DEC128_MIN__ 253*e4b17023SJohn Marino 254*e4b17023SJohn Marino /* Minimum subnormal positive floating-point number. */ 255*e4b17023SJohn Marino #undef DEC32_SUBNORMAL_MIN 256*e4b17023SJohn Marino #undef DEC64_SUBNORMAL_MIN 257*e4b17023SJohn Marino #undef DEC128_SUBNORMAL_MIN 258*e4b17023SJohn Marino #define DEC32_SUBNORMAL_MIN __DEC32_SUBNORMAL_MIN__ 259*e4b17023SJohn Marino #define DEC64_SUBNORMAL_MIN __DEC64_SUBNORMAL_MIN__ 260*e4b17023SJohn Marino #define DEC128_SUBNORMAL_MIN __DEC128_SUBNORMAL_MIN__ 261*e4b17023SJohn Marino 262*e4b17023SJohn Marino /* The floating-point expression evaluation method. 263*e4b17023SJohn Marino -1 indeterminate 264*e4b17023SJohn Marino 0 evaluate all operations and constants just to the range and 265*e4b17023SJohn Marino precision of the type 266*e4b17023SJohn Marino 1 evaluate operations and constants of type _Decimal32 267*e4b17023SJohn Marino and _Decimal64 to the range and precision of the _Decimal64 268*e4b17023SJohn Marino type, evaluate _Decimal128 operations and constants to the 269*e4b17023SJohn Marino range and precision of the _Decimal128 type; 270*e4b17023SJohn Marino 2 evaluate all operations and constants to the range and 271*e4b17023SJohn Marino precision of the _Decimal128 type. */ 272*e4b17023SJohn Marino 273*e4b17023SJohn Marino #undef DEC_EVAL_METHOD 274*e4b17023SJohn Marino #define DEC_EVAL_METHOD __DEC_EVAL_METHOD__ 275*e4b17023SJohn Marino 276*e4b17023SJohn Marino #endif /* __STDC_WANT_DEC_FP__ */ 277*e4b17023SJohn Marino 278*e4b17023SJohn Marino #endif /* _FLOAT_H___ */ 279