float.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #if (defined(__MINGW32__) || defined(_MSC_VER)) && \
  30. defined(__has_include_next) && __has_include_next(<float.h>)
  31. # include_next <float.h>
  32. /* Undefine anything that we'll be redefining below. */
  33. # undef FLT_EVAL_METHOD
  34. # undef FLT_ROUNDS
  35. # undef FLT_RADIX
  36. # undef FLT_MANT_DIG
  37. # undef DBL_MANT_DIG
  38. # undef LDBL_MANT_DIG
  39. # undef DECIMAL_DIG
  40. # undef FLT_DIG
  41. # undef DBL_DIG
  42. # undef LDBL_DIG
  43. # undef FLT_MIN_EXP
  44. # undef DBL_MIN_EXP
  45. # undef LDBL_MIN_EXP
  46. # undef FLT_MIN_10_EXP
  47. # undef DBL_MIN_10_EXP
  48. # undef LDBL_MIN_10_EXP
  49. # undef FLT_MAX_EXP
  50. # undef DBL_MAX_EXP
  51. # undef LDBL_MAX_EXP
  52. # undef FLT_MAX_10_EXP
  53. # undef DBL_MAX_10_EXP
  54. # undef LDBL_MAX_10_EXP
  55. # undef FLT_MAX
  56. # undef DBL_MAX
  57. # undef LDBL_MAX
  58. # undef FLT_EPSILON
  59. # undef DBL_EPSILON
  60. # undef LDBL_EPSILON
  61. # undef FLT_MIN
  62. # undef DBL_MIN
  63. # undef LDBL_MIN
  64. # if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
  65. # undef FLT_TRUE_MIN
  66. # undef DBL_TRUE_MIN
  67. # undef LDBL_TRUE_MIN
  68. # endif
  69. #endif
  70. /* Characteristics of floating point types, C99 5.2.4.2.2 */
  71. #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
  72. #define FLT_ROUNDS (__builtin_flt_rounds())
  73. #define FLT_RADIX __FLT_RADIX__
  74. #define FLT_MANT_DIG __FLT_MANT_DIG__
  75. #define DBL_MANT_DIG __DBL_MANT_DIG__
  76. #define LDBL_MANT_DIG __LDBL_MANT_DIG__
  77. #define DECIMAL_DIG __DECIMAL_DIG__
  78. #define FLT_DIG __FLT_DIG__
  79. #define DBL_DIG __DBL_DIG__
  80. #define LDBL_DIG __LDBL_DIG__
  81. #define FLT_MIN_EXP __FLT_MIN_EXP__
  82. #define DBL_MIN_EXP __DBL_MIN_EXP__
  83. #define LDBL_MIN_EXP __LDBL_MIN_EXP__
  84. #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
  85. #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
  86. #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
  87. #define FLT_MAX_EXP __FLT_MAX_EXP__
  88. #define DBL_MAX_EXP __DBL_MAX_EXP__
  89. #define LDBL_MAX_EXP __LDBL_MAX_EXP__
  90. #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
  91. #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
  92. #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
  93. #define FLT_MAX __FLT_MAX__
  94. #define DBL_MAX __DBL_MAX__
  95. #define LDBL_MAX __LDBL_MAX__
  96. #define FLT_EPSILON __FLT_EPSILON__
  97. #define DBL_EPSILON __DBL_EPSILON__
  98. #define LDBL_EPSILON __LDBL_EPSILON__
  99. #define FLT_MIN __FLT_MIN__
  100. #define DBL_MIN __DBL_MIN__
  101. #define LDBL_MIN __LDBL_MIN__
  102. #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__)
  103. # define FLT_TRUE_MIN __FLT_DENORM_MIN__
  104. # define DBL_TRUE_MIN __DBL_DENORM_MIN__
  105. # define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
  106. #endif
  107. #endif /* __FLOAT_H */