]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multiprecision/example/cpp_bin_float_snips.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / multiprecision / example / cpp_bin_float_snips.cpp
1 ///////////////////////////////////////////////////////////////
2 // Copyright 2013 John Maddock. Distributed under the Boost
3 // Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
5
6 //[cpp_bin_float_eg
7 #include <boost/multiprecision/cpp_bin_float.hpp>
8 #include <boost/math/special_functions/gamma.hpp>
9 #include <iostream>
10
11 int main()
12 {
13 using namespace boost::multiprecision;
14
15 // Operations at fixed precision and full numeric_limits support:
16 cpp_bin_float_100 b = 2;
17 std::cout << std::numeric_limits<cpp_bin_float_100>::digits << std::endl;
18 std::cout << std::numeric_limits<cpp_bin_float_100>::digits10 << std::endl;
19 // We can use any C++ std lib function, lets print all the digits as well:
20 std::cout << std::setprecision(std::numeric_limits<cpp_bin_float_100>::max_digits10)
21 << log(b) << std::endl; // print log(2)
22 // We can also use any function from Boost.Math:
23 std::cout << boost::math::tgamma(b) << std::endl;
24 // These even work when the argument is an expression template:
25 std::cout << boost::math::tgamma(b * b) << std::endl;
26 // And since we have an extended exponent range we can generate some really large
27 // numbers here (4.0238726007709377354370243e+2564):
28 std::cout << boost::math::tgamma(cpp_bin_float_100(1000)) << std::endl;
29 return 0;
30 }
31
32 //]