cstdfloat_types.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright Christopher Kormanyos 2014.
  3. // Copyright John Maddock 2014.
  4. // Copyright Paul Bristow 2014.
  5. // Distributed under the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt
  7. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // Implement the types for floating-point typedefs having specified widths.
  10. #ifndef _BOOST_CSTDFLOAT_TYPES_2014_01_09_HPP_
  11. #define _BOOST_CSTDFLOAT_TYPES_2014_01_09_HPP_
  12. #include <float.h>
  13. #include <limits>
  14. #include <boost/static_assert.hpp>
  15. #include <boost/math/tools/config.hpp>
  16. // This is the beginning of the preamble.
  17. // In this preamble, the preprocessor is used to query certain
  18. // preprocessor definitions from <float.h>. Based on the results
  19. // of these queries, an attempt is made to automatically detect
  20. // the presence of built-in floating-point types having specified
  21. // widths. These are *thought* to be conformant with IEEE-754,
  22. // whereby an unequivocal test based on std::numeric_limits<>
  23. // follows below.
  24. // In addition, various macros that are used for initializing
  25. // floating-point literal values having specified widths and
  26. // some basic min/max values are defined.
  27. // First, we will pre-load certain preprocessor definitions
  28. // with a dummy value.
  29. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 0
  30. #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 0
  31. #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 0
  32. #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 0
  33. #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 0
  34. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 0
  35. // Ensure that the compiler has a radix-2 floating-point representation.
  36. #if (!defined(FLT_RADIX) || ((defined(FLT_RADIX) && (FLT_RADIX != 2))))
  37. #error The compiler does not support any radix-2 floating-point types required for <boost/cstdfloat.hpp>.
  38. #endif
  39. // Check if built-in float is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
  40. #if(defined(FLT_MANT_DIG) && defined(FLT_MAX_EXP))
  41. #if ((FLT_MANT_DIG == 11) && (FLT_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
  42. #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float
  43. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  44. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
  45. #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
  46. #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
  47. #define BOOST_FLOAT16_C(x) (x ## F)
  48. #define BOOST_CSTDFLOAT_FLOAT_16_MIN FLT_MIN
  49. #define BOOST_CSTDFLOAT_FLOAT_16_MAX FLT_MAX
  50. #elif((FLT_MANT_DIG == 24) && (FLT_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
  51. #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float
  52. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  53. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
  54. #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
  55. #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
  56. #define BOOST_FLOAT32_C(x) (x ## F)
  57. #define BOOST_CSTDFLOAT_FLOAT_32_MIN FLT_MIN
  58. #define BOOST_CSTDFLOAT_FLOAT_32_MAX FLT_MAX
  59. #elif((FLT_MANT_DIG == 53) && (FLT_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
  60. #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float
  61. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  62. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
  63. #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
  64. #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
  65. #define BOOST_FLOAT64_C(x) (x ## F)
  66. #define BOOST_CSTDFLOAT_FLOAT_64_MIN FLT_MIN
  67. #define BOOST_CSTDFLOAT_FLOAT_64_MAX FLT_MAX
  68. #elif((FLT_MANT_DIG == 64) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
  69. #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float
  70. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  71. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
  72. #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
  73. #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
  74. #define BOOST_FLOAT80_C(x) (x ## F)
  75. #define BOOST_CSTDFLOAT_FLOAT_80_MIN FLT_MIN
  76. #define BOOST_CSTDFLOAT_FLOAT_80_MAX FLT_MAX
  77. #elif((FLT_MANT_DIG == 113) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
  78. #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float
  79. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  80. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
  81. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  82. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
  83. #define BOOST_FLOAT128_C(x) (x ## F)
  84. #define BOOST_CSTDFLOAT_FLOAT_128_MIN FLT_MIN
  85. #define BOOST_CSTDFLOAT_FLOAT_128_MAX FLT_MAX
  86. #endif
  87. #endif
  88. // Check if built-in double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
  89. #if(defined(DBL_MANT_DIG) && defined(DBL_MAX_EXP))
  90. #if ((DBL_MANT_DIG == 11) && (DBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
  91. #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE double
  92. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  93. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
  94. #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
  95. #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
  96. #define BOOST_FLOAT16_C(x) (x)
  97. #define BOOST_CSTDFLOAT_FLOAT_16_MIN DBL_MIN
  98. #define BOOST_CSTDFLOAT_FLOAT_16_MAX DBL_MAX
  99. #elif((DBL_MANT_DIG == 24) && (DBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
  100. #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE double
  101. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  102. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
  103. #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
  104. #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
  105. #define BOOST_FLOAT32_C(x) (x)
  106. #define BOOST_CSTDFLOAT_FLOAT_32_MIN DBL_MIN
  107. #define BOOST_CSTDFLOAT_FLOAT_32_MAX DBL_MAX
  108. #elif((DBL_MANT_DIG == 53) && (DBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
  109. #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE double
  110. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  111. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
  112. #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
  113. #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
  114. #define BOOST_FLOAT64_C(x) (x)
  115. #define BOOST_CSTDFLOAT_FLOAT_64_MIN DBL_MIN
  116. #define BOOST_CSTDFLOAT_FLOAT_64_MAX DBL_MAX
  117. #elif((DBL_MANT_DIG == 64) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
  118. #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE double
  119. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  120. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
  121. #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
  122. #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
  123. #define BOOST_FLOAT80_C(x) (x)
  124. #define BOOST_CSTDFLOAT_FLOAT_80_MIN DBL_MIN
  125. #define BOOST_CSTDFLOAT_FLOAT_80_MAX DBL_MAX
  126. #elif((DBL_MANT_DIG == 113) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
  127. #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE double
  128. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  129. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
  130. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  131. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
  132. #define BOOST_FLOAT128_C(x) (x)
  133. #define BOOST_CSTDFLOAT_FLOAT_128_MIN DBL_MIN
  134. #define BOOST_CSTDFLOAT_FLOAT_128_MAX DBL_MAX
  135. #endif
  136. #endif
  137. // Disable check long double capability even if supported by compiler since some math runtime
  138. // implementations are broken for long double.
  139. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  140. // Check if built-in long double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t.
  141. #if(defined(LDBL_MANT_DIG) && defined(LDBL_MAX_EXP))
  142. #if ((LDBL_MANT_DIG == 11) && (LDBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0))
  143. #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE long double
  144. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  145. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16
  146. #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
  147. #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1
  148. #define BOOST_FLOAT16_C(x) (x ## L)
  149. #define BOOST_CSTDFLOAT_FLOAT_16_MIN LDBL_MIN
  150. #define BOOST_CSTDFLOAT_FLOAT_16_MAX LDBL_MAX
  151. #elif((LDBL_MANT_DIG == 24) && (LDBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0))
  152. #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE long double
  153. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  154. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32
  155. #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
  156. #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1
  157. #define BOOST_FLOAT32_C(x) (x ## L)
  158. #define BOOST_CSTDFLOAT_FLOAT_32_MIN LDBL_MIN
  159. #define BOOST_CSTDFLOAT_FLOAT_32_MAX LDBL_MAX
  160. #elif((LDBL_MANT_DIG == 53) && (LDBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0))
  161. #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE long double
  162. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  163. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
  164. #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
  165. #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1
  166. #define BOOST_FLOAT64_C(x) (x ## L)
  167. #define BOOST_CSTDFLOAT_FLOAT_64_MIN LDBL_MIN
  168. #define BOOST_CSTDFLOAT_FLOAT_64_MAX LDBL_MAX
  169. #elif((LDBL_MANT_DIG == 64) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0))
  170. #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE long double
  171. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  172. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80
  173. #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
  174. #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1
  175. #define BOOST_FLOAT80_C(x) (x ## L)
  176. #define BOOST_CSTDFLOAT_FLOAT_80_MIN LDBL_MIN
  177. #define BOOST_CSTDFLOAT_FLOAT_80_MAX LDBL_MAX
  178. #elif((LDBL_MANT_DIG == 113) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
  179. #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE long double
  180. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  181. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
  182. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  183. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
  184. #define BOOST_FLOAT128_C(x) (x ## L)
  185. #define BOOST_CSTDFLOAT_FLOAT_128_MIN LDBL_MIN
  186. #define BOOST_CSTDFLOAT_FLOAT_128_MAX LDBL_MAX
  187. #endif
  188. #endif
  189. #endif
  190. // Check if quadruple-precision is supported. Here, we are checking
  191. // for the presence of __float128 from GCC's quadmath.h or _Quad
  192. // from ICC's /Qlong-double flag). To query these, we use the
  193. // BOOST_MATH_USE_FLOAT128 pre-processor definition from
  194. // <boost/math/tools/config.hpp>.
  195. #if (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
  196. // Specify the underlying name of the internal 128-bit floating-point type definition.
  197. namespace boost { namespace math { namespace cstdfloat { namespace detail {
  198. #if defined(__GNUC__)
  199. typedef __float128 float_internal128_t;
  200. #elif defined(BOOST_INTEL)
  201. typedef _Quad float_internal128_t;
  202. #else
  203. #error "Sorry, the compiler is neither GCC, nor Intel, I don't know how to configure <boost/cstdfloat.hpp>."
  204. #endif
  205. } } } } // boost::math::cstdfloat::detail
  206. #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE boost::math::cstdfloat::detail::float_internal128_t
  207. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  208. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128
  209. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  210. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1
  211. #define BOOST_FLOAT128_C(x) (x ## Q)
  212. #define BOOST_CSTDFLOAT_FLOAT128_MIN 3.36210314311209350626267781732175260e-4932Q
  213. #define BOOST_CSTDFLOAT_FLOAT128_MAX 1.18973149535723176508575932662800702e+4932Q
  214. #define BOOST_CSTDFLOAT_FLOAT128_EPS 1.92592994438723585305597794258492732e-0034Q
  215. #define BOOST_CSTDFLOAT_FLOAT128_DENORM_MIN 6.475175119438025110924438958227646552e-4966Q
  216. #endif // Not BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support)
  217. // This is the end of the preamble, and also the end of the
  218. // sections providing support for the C++ standard library
  219. // for quadruple-precision.
  220. // Now we use the results of the queries that have been obtained
  221. // in the preamble (far above) for the final type definitions in
  222. // the namespace boost.
  223. // Make sure that the compiler has any floating-point type(s) whatsoever.
  224. #if ( (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0) \
  225. && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0) \
  226. && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0) \
  227. && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0) \
  228. && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0))
  229. #error The compiler does not support any of the floating-point types required for <boost/cstdfloat.hpp>.
  230. #endif
  231. // The following section contains the various min/max macros
  232. // for the *leastN and *fastN types.
  233. #if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1)
  234. #define BOOST_FLOAT_FAST16_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN
  235. #define BOOST_FLOAT_LEAST16_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN
  236. #define BOOST_FLOAT_FAST16_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX
  237. #define BOOST_FLOAT_LEAST16_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX
  238. #endif
  239. #if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1)
  240. #define BOOST_FLOAT_FAST32_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN
  241. #define BOOST_FLOAT_LEAST32_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN
  242. #define BOOST_FLOAT_FAST32_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX
  243. #define BOOST_FLOAT_LEAST32_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX
  244. #endif
  245. #if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1)
  246. #define BOOST_FLOAT_FAST64_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN
  247. #define BOOST_FLOAT_LEAST64_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN
  248. #define BOOST_FLOAT_FAST64_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX
  249. #define BOOST_FLOAT_LEAST64_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX
  250. #endif
  251. #if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1)
  252. #define BOOST_FLOAT_FAST80_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN
  253. #define BOOST_FLOAT_LEAST80_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN
  254. #define BOOST_FLOAT_FAST80_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX
  255. #define BOOST_FLOAT_LEAST80_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX
  256. #endif
  257. #if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1)
  258. #define BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T
  259. #define BOOST_FLOAT_FAST128_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN
  260. #define BOOST_FLOAT_LEAST128_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN
  261. #define BOOST_FLOAT_FAST128_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX
  262. #define BOOST_FLOAT_LEAST128_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX
  263. #endif
  264. // The following section contains the various min/max macros
  265. // for the *floatmax types.
  266. #if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16)
  267. #define BOOST_FLOATMAX_C(x) BOOST_FLOAT16_C(x)
  268. #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN
  269. #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX
  270. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32)
  271. #define BOOST_FLOATMAX_C(x) BOOST_FLOAT32_C(x)
  272. #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN
  273. #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX
  274. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64)
  275. #define BOOST_FLOATMAX_C(x) BOOST_FLOAT64_C(x)
  276. #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN
  277. #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX
  278. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80)
  279. #define BOOST_FLOATMAX_C(x) BOOST_FLOAT80_C(x)
  280. #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN
  281. #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX
  282. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128)
  283. #define BOOST_FLOATMAX_C(x) BOOST_FLOAT128_C(x)
  284. #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN
  285. #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX
  286. #else
  287. #error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined.
  288. #endif
  289. // And finally..., we define the floating-point typedefs having
  290. // specified widths. The types are defined in the namespace boost.
  291. // For simplicity, the least and fast types are type defined identically
  292. // as the corresponding fixed-width type. This behavior may, however,
  293. // be modified when being optimized for a given compiler implementation.
  294. // In addition, a clear assessment of IEEE-754 comformance is carried out
  295. // using compile-time assertion.
  296. namespace boost
  297. {
  298. #if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1)
  299. typedef BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float16_t;
  300. typedef boost::float16_t float_fast16_t;
  301. typedef boost::float16_t float_least16_t;
  302. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::is_iec559 == true, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  303. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::radix == 2, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  304. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::digits == 11, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  305. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::max_exponent == 16, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  306. #undef BOOST_CSTDFLOAT_FLOAT_16_MIN
  307. #undef BOOST_CSTDFLOAT_FLOAT_16_MAX
  308. #endif
  309. #if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1)
  310. typedef BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float32_t;
  311. typedef boost::float32_t float_fast32_t;
  312. typedef boost::float32_t float_least32_t;
  313. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::is_iec559 == true, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  314. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::radix == 2, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  315. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::digits == 24, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  316. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::max_exponent == 128, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  317. #undef BOOST_CSTDFLOAT_FLOAT_32_MIN
  318. #undef BOOST_CSTDFLOAT_FLOAT_32_MAX
  319. #endif
  320. #if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && defined(__SUNPRO_CC)
  321. #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
  322. #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 0
  323. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  324. #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 0
  325. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  326. #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64
  327. #endif
  328. #if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1)
  329. typedef BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float64_t;
  330. typedef boost::float64_t float_fast64_t;
  331. typedef boost::float64_t float_least64_t;
  332. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::is_iec559 == true, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  333. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::radix == 2, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  334. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::digits == 53, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  335. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::max_exponent == 1024, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  336. #undef BOOST_CSTDFLOAT_FLOAT_64_MIN
  337. #undef BOOST_CSTDFLOAT_FLOAT_64_MAX
  338. #endif
  339. #if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1)
  340. typedef BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float80_t;
  341. typedef boost::float80_t float_fast80_t;
  342. typedef boost::float80_t float_least80_t;
  343. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::is_iec559 == true, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  344. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::radix == 2, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  345. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::digits == 64, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  346. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::max_exponent == 16384, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  347. #undef BOOST_CSTDFLOAT_FLOAT_80_MIN
  348. #undef BOOST_CSTDFLOAT_FLOAT_80_MAX
  349. #endif
  350. #if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1)
  351. typedef BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float128_t;
  352. typedef boost::float128_t float_fast128_t;
  353. typedef boost::float128_t float_least128_t;
  354. #if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
  355. // This configuration does not *yet* support std::numeric_limits<boost::float128_t>.
  356. // Support for std::numeric_limits<boost::float128_t> is added in the detail
  357. // file <boost/math/cstdfloat/cstdfloat_limits.hpp>.
  358. #else
  359. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::is_iec559 == true, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  360. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::radix == 2, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  361. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::digits == 113, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  362. BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::max_exponent == 16384, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails");
  363. #endif
  364. #undef BOOST_CSTDFLOAT_FLOAT_128_MIN
  365. #undef BOOST_CSTDFLOAT_FLOAT_128_MAX
  366. #endif
  367. #if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16)
  368. typedef boost::float16_t floatmax_t;
  369. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32)
  370. typedef boost::float32_t floatmax_t;
  371. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64)
  372. typedef boost::float64_t floatmax_t;
  373. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80)
  374. typedef boost::float80_t floatmax_t;
  375. #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128)
  376. typedef boost::float128_t floatmax_t;
  377. #else
  378. #error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined.
  379. #endif
  380. #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE
  381. #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE
  382. #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE
  383. #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE
  384. #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE
  385. #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH
  386. }
  387. // namespace boost
  388. #endif // _BOOST_CSTDFLOAT_BASE_TYPES_2014_01_09_HPP_