cstdfloat_example.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. // Copyright John Maddock 2014
  2. // Copyright Christopher Kormanyos 2014.
  3. // Copyright Paul A. Bristow 2016.
  4. // Use, modification and distribution are subject to the
  5. // Boost Software License, Version 1.0. (See accompanying file
  6. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. // Contains Quickbook snippets as C++ comments - do not remove.
  8. /*
  9. `This example shows use of a specified-width floating-point typedef
  10. to evaluate a moderately complex math function using
  11. [@http://en.wikipedia.org/wiki/Double-precision_floating-point_format IEEE754 64-bit double-precision].
  12. about 15 decimal digits `std::numeric_limits<boost::float64_t>::digits10`,
  13. (but never exceeding 17 decimal digits `std::numeric_limits<boost::float64_t>::max_digits10`).
  14. The Jahnke-Emden lambda function is described at
  15. Weisstein, Eric W. "Lambda Function." From MathWorld--A Wolfram Web Resource.
  16. http://mathworld.wolfram.com/LambdaFunction.html
  17. E. Jahnke and F. Emden, "Tables of Functions with Formulae and Curves,"
  18. Dover, New York, 4th ed., (1945), pages 180-188.
  19. */
  20. //[cstdfloat_example_1
  21. #include <boost/cstdfloat.hpp> // For float_64_t, float128_t. Must be first include!
  22. #include <cmath> // for pow function.
  23. #include <boost/math/special_functions.hpp> // For gamma function.
  24. //] [/cstdfloat_example_1]
  25. #include <boost/type_traits/is_same.hpp>
  26. #include <iostream>
  27. /*!
  28. Function max_digits10
  29. Returns maximum number of possibly significant decimal digits for a floating-point type FPT,
  30. even for older compilers/standard libraries that
  31. lack support for std::numeric_limits<FPT>::max_digits10,
  32. when the Kahan formula 2 + binary_digits * 0.3010 is used instead.
  33. Also provides the correct result for Visual Studio 2010
  34. (where the value 8 provided for float is wrong).
  35. */
  36. namespace boost
  37. {
  38. template <typename FPT>
  39. const int max_digits10()
  40. {
  41. // Since max_digits10 is not defined (or wrong) on older systems, define a local max_digits10.
  42. // Usage: int m = max_digits10<boost::float64_t>();
  43. const int m =
  44. #if (defined BOOST_NO_CXX11_NUMERIC_LIMITS) || (_MSC_VER == 1600) // is wrongly 8 not 9 for VS2010.
  45. 2 + std::numeric_limits<FPT>::digits * 3010/10000;
  46. #else
  47. std::numeric_limits<FPT>::max_digits10;
  48. #endif
  49. return m;
  50. }
  51. } // namespace boost
  52. //`Define the Jahnke-Emden_lambda function.
  53. //[cstdfloat_example_2
  54. boost::float64_t jahnke_emden_lambda(boost::float64_t v, boost::float64_t x)
  55. {
  56. const boost::float64_t gamma_v_plus_one = boost::math::tgamma(v + 1);
  57. const boost::float64_t x_half_pow_v = std::pow(x /2, v);
  58. return gamma_v_plus_one * boost::math::cyl_bessel_j(x, v) / x_half_pow_v;
  59. }
  60. //] [/cstdfloat_example_2]
  61. int main()
  62. {
  63. std::cout.setf(std::ios::showpoint); // show all significant trailing zeros.
  64. long double p = 1.L;
  65. //std::cout.precision(std::numeric_limits<long double>::digits10);
  66. std::cout << "pi = " << p << std::endl;
  67. //[cstdfloat_example_3
  68. //`Ensure that all possibly significant digits (17) including trailing zeros are shown.
  69. std::cout.precision(std::numeric_limits<boost::float64_t>::max_digits10);
  70. std::cout.setf(std::ios::showpoint); // Show trailing zeros.
  71. try
  72. { // Always use try'n'catch blocks to ensure any error messages are displayed.
  73. // Evaluate and display an evaluation of the Jahnke-Emden lambda function:
  74. boost::float64_t v = 1.;
  75. boost::float64_t x = 1.;
  76. std::cout << jahnke_emden_lambda(v, x) << std::endl; // 0.88010117148986700
  77. //] [/cstdfloat_example_3]
  78. // We can show some evaluations with various precisions:
  79. { // float64_t
  80. for (int i = 0; i < 10; i++)
  81. {
  82. std::cout << std::setprecision(2) << boost::float64_t(i) << ' '
  83. << std::setprecision(std::numeric_limits<boost::float64_t>::max_digits10)
  84. << jahnke_emden_lambda(boost::float64_t(i), v) << std::endl; //
  85. }
  86. }
  87. { // floatmax_t = the maximum available on this platform.
  88. for (int i = 0; i < 10; i++)
  89. {
  90. std::cout << std::setprecision(2) << boost::floatmax_t(i) << ' '
  91. << std::setprecision(std::numeric_limits<boost::floatmax_t>::max_digits10)
  92. << jahnke_emden_lambda(boost::floatmax_t(i), v) << std::endl; //
  93. }
  94. }
  95. // Show the precision of long double (this might be 64, 80 or 128 bits).
  96. std::cout << "Floating-point type long double is available with:" << std::endl;
  97. std::cout << " std::numeric_limits<long double>::digits10 == "
  98. << std::numeric_limits<long double>::digits10 << std::endl; // 18
  99. std::cout << " std::numeric_limits<long double>::max_digits10 == "
  100. << std::numeric_limits<long double>::max_digits10 << std::endl; // 21
  101. long double p = boost::math::constants::pi<double>();
  102. std::cout.precision(std::numeric_limits<long double>::digits10);
  103. std::cout << "pi = " << p << std::endl;
  104. //[cstdfloat_constant_2
  105. //`These allow floating-point [*constants of at least the specified width] to be declared:
  106. // Declare Archimedes' constant using float32_t with approximately 7 decimal digits of precision.
  107. static const boost::float32_t pi = BOOST_FLOAT32_C(3.1415926536);
  108. // Declare the Euler-gamma constant with approximately 15 decimal digits of precision.
  109. static const boost::float64_t euler =
  110. BOOST_FLOAT64_C(0.57721566490153286060651209008240243104216);
  111. // Declare the Golden Ratio constant with the maximum decimal digits of precision that the platform supports.
  112. static const boost::floatmax_t golden_ratio =
  113. BOOST_FLOATMAX_C(1.61803398874989484820458683436563811772);
  114. //] [/cstdfloat_constant_2]
  115. // http://www.boost.org/doc/libs/1_55_0/libs/multiprecision/doc/html/boost_multiprecision/tut/floats/float128.html
  116. //[cstdfloat_constant_1
  117. // Display the constant pi to the maximum available precision.
  118. boost::floatmax_t pi_max = boost::math::constants::pi<boost::floatmax_t>();
  119. std::cout.precision(std::numeric_limits<boost::floatmax_t>::digits10);
  120. std::cout << "Most precise pi = " << pi_max << std::endl;
  121. // If floatmax_t is float_128_t, then
  122. // Most precise pi = 3.141592653589793238462643383279503
  123. //] [/cstdfloat_constant_1]
  124. // Test all the floating-point precisions in turn, and if they are available
  125. // then display how many decimal digits of precision.
  126. #ifdef BOOST_FLOAT16_C
  127. std::cout << "Floating-point type boost::float16_t is available." << std::endl;
  128. #else
  129. std::cout << "Floating-point type boost::float16_t is NOT available." << std::endl;
  130. #endif
  131. #ifdef BOOST_FLOAT32_C
  132. std::cout << "Floating-point type boost::float32_t is available." << std::endl;
  133. std::cout << " std::numeric_limits<boost::float32_t>::digits10 == "
  134. << std::numeric_limits<boost::float32_t>::digits10 << std::endl;
  135. std::cout << " std::numeric_limits<boost::float32_t>::max_digits10 == "
  136. << std::numeric_limits<boost::float32_t>::max_digits10 << std::endl;
  137. #else
  138. std::cout << "Floating-point type boost::float32_t is NOT available." << std::endl;
  139. #endif
  140. #ifdef BOOST_FLOAT64_C
  141. std::cout << "Floating-point type boost::float64_t is available." << std::endl;
  142. std::cout << " std::numeric_limits<boost::float64_t>::digits10 == "
  143. << std::numeric_limits<boost::float64_t>::digits10 << std::endl;
  144. std::cout << " std::numeric_limits<boost::float64_t>::max_digits10 == "
  145. << std::numeric_limits<boost::float64_t>::max_digits10 << std::endl;
  146. #else
  147. std::cout << "Floating-point type boost::float64_t is NOT available." << std::endl;
  148. #endif
  149. #ifdef BOOST_FLOAT80_C
  150. std::cout << "Floating-point type boost::float80_t is available." << std::endl;
  151. std::cout << " std::numeric_limits<boost::float80_t>::digits10 == "
  152. << std::numeric_limits<boost::float80_t>::digits10 << std::endl;
  153. std::cout << " std::numeric_limits<boost::float80_t>::max_digits10 == "
  154. << std::numeric_limits<boost::float80_t>::max_digits10 << std::endl;
  155. #else
  156. std::cout << "Floating-point type boost::float80_t is NOT available." << std::endl;
  157. #endif
  158. #ifdef BOOST_FLOAT128_C
  159. std::cout << "Floating-point type boost::float128_t is available." << std::endl;
  160. std::cout << " std::numeric_limits<boost::float128_t>::digits10 == "
  161. << std::numeric_limits<boost::float128_t>::digits10 << std::endl;
  162. std::cout << " std::numeric_limits<boost::float128_t>::max_digits10 == "
  163. << std::numeric_limits<boost::float128_t>::max_digits10 << std::endl;
  164. #else
  165. std::cout << "Floating-point type boost::float128_t is NOT available." << std::endl;
  166. #endif
  167. // Show some constants at a precision depending on the available type(s).
  168. #ifdef BOOST_FLOAT16_C
  169. std::cout.precision(boost::max_digits10<boost::float16_t>()); // Show all significant decimal digits,
  170. std::cout.setf(std::ios::showpoint); // including all significant trailing zeros.
  171. std::cout << "BOOST_FLOAT16_C(123.456789012345678901234567890) = "
  172. << BOOST_FLOAT16_C(123.456789012345678901234567890) << std::endl;
  173. // BOOST_FLOAT16_C(123.456789012345678901234567890) = 123.45678901234568
  174. #endif
  175. //[floatmax_widths_1
  176. #ifdef BOOST_FLOAT32_C
  177. std::cout.precision(boost::max_digits10<boost::float32_t>()); // Show all significant decimal digits,
  178. std::cout.setf(std::ios::showpoint); // including all significant trailing zeros.
  179. std::cout << "BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = "
  180. << BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) << std::endl;
  181. // BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787
  182. #endif
  183. //] [/floatmax_widths_1]
  184. #ifdef BOOST_FLOAT64_C
  185. std::cout.precision(boost::max_digits10<boost::float64_t>()); // Show all significant decimal digits,
  186. std::cout.setf(std::ios::showpoint); // including all significant trailing zeros.
  187. std::cout << "BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = "
  188. << BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) << std::endl;
  189. // BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = 123.45678901234568
  190. #endif
  191. #ifdef BOOST_FLOAT80_C
  192. std::cout.precision(boost::max_digits10<boost::float80_t>()); // Show all significant decimal digits,
  193. std::cout.setf(std::ios::showpoint); // including all significant trailing zeros.
  194. std::cout << "BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) = "
  195. << BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) << std::endl;
  196. // BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) = 123.456789012345678903
  197. #endif
  198. #ifdef BOOST_FLOAT128_C
  199. std::cout.precision(boost::max_digits10<boost::float128_t>()); // Show all significant decimal digits,
  200. std::cout.setf(std::ios::showpoint); // including all significant trailing zeros.
  201. std::cout << "BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) = "
  202. << BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) << std::endl;
  203. // BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) = 123.456789012345678901234567890123453
  204. #endif
  205. /*
  206. //[floatmax_widths_2
  207. BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787
  208. BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = 123.45678901234568
  209. BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) = 123.456789012345678903
  210. BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) = 123.456789012345678901234567890123453
  211. //] [/floatmax_widths_2]
  212. */
  213. // Display the precisions available for floatmax_t
  214. #ifdef BOOST_FLOATMAX_C
  215. BOOST_ASSERT(std::numeric_limits<boost::floatmax_t>::is_specialized == true);
  216. BOOST_ASSERT(std::numeric_limits<boost::floatmax_t>::is_iec559 == true);
  217. BOOST_ASSERT(BOOST_FLOATMAX_C(0.) == 0);
  218. std::cout << "floatmax_t " << std::numeric_limits<boost::floatmax_t>::digits << " bits\n" // 113
  219. << std::numeric_limits<boost::floatmax_t>::digits10 << " decimal digits\n" // 34
  220. << std::numeric_limits<boost::floatmax_t>::max_digits10 << " max_digits\n" // 36
  221. << std::numeric_limits<boost::floatmax_t>::radix << " radix\n"
  222. << std::endl;
  223. int significand_bits = std::numeric_limits<boost::floatmax_t>::digits;
  224. int exponent_max = std::numeric_limits<boost::floatmax_t>::max_exponent;
  225. int exponent_min = std::numeric_limits<boost::floatmax_t>::min_exponent;
  226. int exponent_bits = 1 + static_cast<int>(std::log2(std::numeric_limits<boost::floatmax_t>::max_exponent));
  227. int sign_bits = std::numeric_limits<boost::floatmax_t>::is_signed;
  228. std::cout << "significand_bits (including one implicit bit)" << significand_bits
  229. << ", exponent_bits " << exponent_bits
  230. << ", sign_bits " << sign_bits << std::endl;
  231. // One can compute the total number of bits in the floatmax_t,
  232. // but probably not at compile time.
  233. std::cout << "bits = " << significand_bits + exponent_bits + sign_bits -1 << std::endl;
  234. // -1 to take account of the implicit bit that is not part of the physical layout.
  235. // One can compare typedefs (but, of course, only those that are defined for the platform in use.)
  236. std::cout.setf(std::ios::boolalpha);
  237. std::cout << "double, double: " << std::is_same<double, double>::value << std::endl;
  238. bool b = boost::is_same<boost::floatmax_t, boost::float64_t>::value;
  239. std::cout << "boost::is_same<boost::floatmax_t, boost::float64_t>::value; " << b << std::endl;
  240. std::cout << "floatmax_t, float64_t: "
  241. << std::is_same<boost::floatmax_t, boost::float64_t>::value << std::endl;
  242. /*`So the simplest way of obtaining the total number of bits in the floatmax_t
  243. is to infer it from the std::numeric_limits<>::digits value.
  244. This is possible because the type, must be a IEEE754 layout. */
  245. //[floatmax_1
  246. const int fpbits =
  247. (std::numeric_limits<boost::floatmax_t>::digits == 113) ? 128 :
  248. (std::numeric_limits<boost::floatmax_t>::digits == 64) ? 80 :
  249. (std::numeric_limits<boost::floatmax_t>::digits == 53) ? 64 :
  250. (std::numeric_limits<boost::floatmax_t>::digits == 24) ? 32 :
  251. (std::numeric_limits<boost::floatmax_t>::digits == 11) ? 16 :
  252. 0; // Unknown - not IEEE754 format.
  253. std::cout << fpbits << " bits." << std::endl;
  254. //] [/floatmax_1]
  255. #endif
  256. }
  257. catch (std::exception ex)
  258. { // Display details about why any exceptions are thrown.
  259. std::cout << "Thrown exception " << ex.what() << std::endl;
  260. }
  261. } // int main()
  262. /*
  263. [cstdfloat_output
  264. GCC 4.8.1 with quadmath
  265. pi = 1.00000
  266. 0.88010117148986700
  267. 0.0 0.0000000000000000
  268. 1.0 0.88010117148986700
  269. 2.0 4.6137984620549872
  270. 3.0 16.274830009244951
  271. 4.0 -25.360637961042869
  272. 5.0 -1257.9038883512264
  273. 6.0 -12749.592182518225
  274. 7.0 -3020.9830849309437
  275. 8.0 2421897.6013183584
  276. 9.0 45577595.449204877
  277. 0.0 0.00000000000000000000000000000000000
  278. 1.0 0.880101171489866995756301548681221902
  279. 2.0 4.61379846205498722611082484945654869
  280. 3.0 16.2748300092449511566883302293717861
  281. 4.0 -25.3606379610428689375112298876047134
  282. 5.0 -1257.90388835122644195507746189832687
  283. 6.0 -12749.5921825182249449426308274269104
  284. 7.0 -3020.98308493094373261556029319763184
  285. 8.0 2421897.60131835844367742538452148438
  286. 9.0 45577595.4492048770189285278320312500
  287. Floating-point type long double is available with:
  288. std::numeric_limits<long double>::digits10 == 18
  289. std::numeric_limits<long double>::max_digits10 == 21
  290. pi = 3.14159265358979312
  291. Most precise pi = 3.141592653589793238462643383279503
  292. Floating-point type boost::float16_t is NOT available.
  293. Floating-point type boost::float32_t is available.
  294. std::numeric_limits<boost::float32_t>::digits10 == 6
  295. std::numeric_limits<boost::float32_t>::max_digits10 == 9
  296. Floating-point type boost::float64_t is available.
  297. std::numeric_limits<boost::float64_t>::digits10 == 15
  298. std::numeric_limits<boost::float64_t>::max_digits10 == 17
  299. Floating-point type boost::float80_t is available.
  300. std::numeric_limits<boost::float80_t>::digits10 == 18
  301. std::numeric_limits<boost::float80_t>::max_digits10 == 21
  302. Floating-point type boost::float128_t is available.
  303. std::numeric_limits<boost::float128_t>::digits10 == 34
  304. std::numeric_limits<boost::float128_t>::max_digits10 == 36
  305. BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787
  306. BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = 123.45678901234568
  307. BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) = 123.456789012345678903
  308. BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) = 123.456789012345678901234567890123453
  309. floatmax_t 113 bits
  310. 34 decimal digits
  311. 36 max_digits
  312. 2 radix
  313. significand_bits (including one implicit bit)113, exponent_bits 15, sign_bits 1
  314. bits = 128
  315. double, double: true
  316. boost::is_same<boost::floatmax_t, boost::float64_t>::value; false
  317. floatmax_t, float64_t: false
  318. 128 bits.
  319. RUN SUCCESSFUL (total time: 53ms)
  320. GCC 6.1.1
  321. pi = 1.00000
  322. 0.88010117148986700
  323. 0.0 0.0000000000000000
  324. 1.0 0.88010117148986700
  325. 2.0 4.6137984620549872
  326. 3.0 16.274830009244951
  327. 4.0 -25.360637961042869
  328. 5.0 -1257.9038883512264
  329. 6.0 -12749.592182518225
  330. 7.0 -3020.9830849309437
  331. 8.0 2421897.6013183584
  332. 9.0 45577595.449204877
  333. 0.0 0.00000000000000000000000000000000000
  334. 1.0 0.880101171489866995756301548681221902
  335. 2.0 4.61379846205498722611082484945654869
  336. 3.0 16.2748300092449511566883302293717861
  337. 4.0 -25.3606379610428689375112298876047134
  338. 5.0 -1257.90388835122644195507746189832687
  339. 6.0 -12749.5921825182249449426308274269104
  340. 7.0 -3020.98308493094373261556029319763184
  341. 8.0 2421897.60131835844367742538452148438
  342. 9.0 45577595.4492048770189285278320312500
  343. Floating-point type long double is available with:
  344. std::numeric_limits<long double>::digits10 == 18
  345. std::numeric_limits<long double>::max_digits10 == 21
  346. pi = 3.14159265358979312
  347. Most precise pi = 3.14159265358979323846264338327950
  348. Floating-point type boost::float16_t is NOT available.
  349. Floating-point type boost::float32_t is available.
  350. std::numeric_limits<boost::float32_t>::digits10 == 6
  351. std::numeric_limits<boost::float32_t>::max_digits10 == 9
  352. Floating-point type boost::float64_t is available.
  353. std::numeric_limits<boost::float64_t>::digits10 == 15
  354. std::numeric_limits<boost::float64_t>::max_digits10 == 17
  355. Floating-point type boost::float80_t is available.
  356. std::numeric_limits<boost::float80_t>::digits10 == 18
  357. std::numeric_limits<boost::float80_t>::max_digits10 == 21
  358. Floating-point type boost::float128_t is available.
  359. std::numeric_limits<boost::float128_t>::digits10 == 33
  360. std::numeric_limits<boost::float128_t>::max_digits10 == 36
  361. BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787
  362. BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = 123.45678901234568
  363. BOOST_FLOAT80_C(123.4567890123456789012345678901234567890) = 123.456789012345678903
  364. BOOST_FLOAT128_C(123.4567890123456789012345678901234567890) = 123.456789012345678901234567890123453
  365. floatmax_t 113 bits
  366. 33 decimal digits
  367. 36 max_digits
  368. 2 radix
  369. significand_bits (including one implicit bit)113, exponent_bits 15, sign_bits 1
  370. bits = 128
  371. double, double: true
  372. boost::is_same<boost::floatmax_t, boost::float64_t>::value; false
  373. floatmax_t, float64_t: false
  374. 128 bits.
  375. MSVC 2013 64-bit
  376. 1> pi = 1.00000
  377. 1> 0.88010117148986700
  378. 1> 0.00 0.00000000000000000
  379. 1> 1.0 0.88010117148986700
  380. 1> 2.0 4.6137984620549854
  381. 1> 3.0 16.274830009244948
  382. 1> 4.0 -25.360637961042869
  383. 1> 5.0 -1257.9038883512258
  384. 1> 6.0 -12749.592182518225
  385. 1> 7.0 -3020.9830849309396
  386. 1> 8.0 2421897.6013183575
  387. 1> 9.0 45577595.449204892
  388. 1> 0.00 0.00000000000000000
  389. 1> 1.0 0.88010117148986700
  390. 1> 2.0 4.6137984620549854
  391. 1> 3.0 16.274830009244948
  392. 1> 4.0 -25.360637961042869
  393. 1> 5.0 -1257.9038883512258
  394. 1> 6.0 -12749.592182518225
  395. 1> 7.0 -3020.9830849309396
  396. 1> 8.0 2421897.6013183575
  397. 1> 9.0 45577595.449204892
  398. 1> Floating-point type long double is available with:
  399. 1> std::numeric_limits<long double>::digits10 == 15
  400. 1> std::numeric_limits<long double>::max_digits10 == 17
  401. 1> pi = 3.14159265358979
  402. 1> Most precise pi = 3.14159265358979
  403. 1> Floating-point type boost::float16_t is NOT available.
  404. 1> Floating-point type boost::float32_t is available.
  405. 1> std::numeric_limits<boost::float32_t>::digits10 == 6
  406. 1> std::numeric_limits<boost::float32_t>::max_digits10 == 9
  407. 1> Floating-point type boost::float64_t is available.
  408. 1> std::numeric_limits<boost::float64_t>::digits10 == 15
  409. 1> std::numeric_limits<boost::float64_t>::max_digits10 == 17
  410. 1> Floating-point type boost::float80_t is NOT available.
  411. 1> Floating-point type boost::float128_t is NOT available.
  412. 1> BOOST_FLOAT32_C(123.4567890123456789012345678901234567890) = 123.456787
  413. 1> BOOST_FLOAT64_C(123.4567890123456789012345678901234567890) = 123.45678901234568
  414. 1> floatmax_t 53 bits
  415. 1> 15 decimal digits
  416. 1> 17 max_digits
  417. 1> 2 radix
  418. 1>
  419. 1> significand_bits (including one implicit bit)53, exponent_bits 11, sign_bits 1
  420. 1> bits = 64
  421. 1> double, double: true
  422. 1> boost::is_same<boost::floatmax_t, boost::float64_t>::value; true
  423. 1> floatmax_t, float64_t: true
  424. 1> 64 bits.
  425. ] [/cstdfloat_output]
  426. */