float.h 8.5 KB

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