float.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*===---- float.h - Characteristics of floating point types ----------------===
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. *
  21. *===-----------------------------------------------------------------------===
  22. */
  23. #ifndef __FLOAT_H
  24. #define __FLOAT_H
  25. /* If we're on MinGW, fall back to the system's float.h, which might have
  26. * additional definitions provided for Windows.
  27. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  28. *
  29. * Also fall back on Darwin to allow additional definitions and
  30. * implementation-defined values.
  31. */
  32. #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
  33. __STDC_HOSTED__ && __has_include_next(<float.h>)
  34. /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
  35. * of #include_next<float.h> to keep Metrowerks compilers happy. Avoid this
  36. * extra indirection.
  37. */
  38. #ifdef __APPLE__
  39. #define _FLOAT_H_
  40. #endif
  41. # include_next <float.h>
  42. /* Undefine anything that we'll be redefining below. */
  43. # undef FLT_EVAL_METHOD
  44. # undef FLT_ROUNDS
  45. # undef FLT_RADIX
  46. # undef FLT_MANT_DIG
  47. # undef DBL_MANT_DIG
  48. # undef LDBL_MANT_DIG
  49. # if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
  50. # undef DECIMAL_DIG
  51. # endif
  52. # undef FLT_DIG
  53. # undef DBL_DIG
  54. # undef LDBL_DIG
  55. # undef FLT_MIN_EXP
  56. # undef DBL_MIN_EXP
  57. # undef LDBL_MIN_EXP
  58. # undef FLT_MIN_10_EXP
  59. # undef DBL_MIN_10_EXP
  60. # undef LDBL_MIN_10_EXP
  61. # undef FLT_MAX_EXP
  62. # undef DBL_MAX_EXP
  63. # undef LDBL_MAX_EXP
  64. # undef FLT_MAX_10_EXP
  65. # undef DBL_MAX_10_EXP
  66. # undef LDBL_MAX_10_EXP
  67. # undef FLT_MAX
  68. # undef DBL_MAX
  69. # undef LDBL_MAX
  70. # undef FLT_EPSILON
  71. # undef DBL_EPSILON
  72. # undef LDBL_EPSILON
  73. # undef FLT_MIN
  74. # undef DBL_MIN
  75. # undef LDBL_MIN
  76. # if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
  77. # undef FLT_TRUE_MIN
  78. # undef DBL_TRUE_MIN
  79. # undef LDBL_TRUE_MIN
  80. # undef FLT_DECIMAL_DIG
  81. # undef DBL_DECIMAL_DIG
  82. # undef LDBL_DECIMAL_DIG
  83. # endif
  84. #endif
  85. /* Characteristics of floating point types, C99 5.2.4.2.2 */
  86. #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
  87. #define FLT_ROUNDS (__builtin_flt_rounds())
  88. #define FLT_RADIX __FLT_RADIX__
  89. #define FLT_MANT_DIG __FLT_MANT_DIG__
  90. #define DBL_MANT_DIG __DBL_MANT_DIG__
  91. #define LDBL_MANT_DIG __LDBL_MANT_DIG__
  92. #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__)
  93. # define DECIMAL_DIG __DECIMAL_DIG__
  94. #endif
  95. #define FLT_DIG __FLT_DIG__
  96. #define DBL_DIG __DBL_DIG__
  97. #define LDBL_DIG __LDBL_DIG__
  98. #define FLT_MIN_EXP __FLT_MIN_EXP__
  99. #define DBL_MIN_EXP __DBL_MIN_EXP__
  100. #define LDBL_MIN_EXP __LDBL_MIN_EXP__
  101. #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
  102. #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
  103. #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
  104. #define FLT_MAX_EXP __FLT_MAX_EXP__
  105. #define DBL_MAX_EXP __DBL_MAX_EXP__
  106. #define LDBL_MAX_EXP __LDBL_MAX_EXP__
  107. #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
  108. #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
  109. #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
  110. #define FLT_MAX __FLT_MAX__
  111. #define DBL_MAX __DBL_MAX__
  112. #define LDBL_MAX __LDBL_MAX__
  113. #define FLT_EPSILON __FLT_EPSILON__
  114. #define DBL_EPSILON __DBL_EPSILON__
  115. #define LDBL_EPSILON __LDBL_EPSILON__
  116. #define FLT_MIN __FLT_MIN__
  117. #define DBL_MIN __DBL_MIN__
  118. #define LDBL_MIN __LDBL_MIN__
  119. #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
  120. # define FLT_TRUE_MIN __FLT_DENORM_MIN__
  121. # define DBL_TRUE_MIN __DBL_DENORM_MIN__
  122. # define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
  123. # define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
  124. # define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
  125. # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
  126. #endif
  127. #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
  128. # define FLT16_MANT_DIG __FLT16_MANT_DIG__
  129. # define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
  130. # define FLT16_DIG __FLT16_DIG__
  131. # define FLT16_MIN_EXP __FLT16_MIN_EXP__
  132. # define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__
  133. # define FLT16_MAX_EXP __FLT16_MAX_EXP__
  134. # define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__
  135. # define FLT16_MAX __FLT16_MAX__
  136. # define FLT16_EPSILON __FLT16_EPSILON__
  137. # define FLT16_MIN __FLT16_MIN__
  138. # define FLT16_TRUE_MIN __FLT16_TRUE_MIN__
  139. #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
  140. #endif /* __FLOAT_H */