• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 https://www.boost.org/LICENSE_1_0.txt
5 
6 //[cpp_bin_float_eg
7 #include <boost/multiprecision/cpp_bin_float.hpp>
8 #include <boost/math/special_functions/gamma.hpp>
9 
10 #include <iostream>
11 
main()12 int main()
13 {
14    using namespace boost::multiprecision;
15 
16    // Operations at fixed precision and full numeric_limits support:
17    cpp_bin_float_100 b = 2;
18    std::cout << std::numeric_limits<cpp_bin_float_100>::digits << std::endl;
19    std::cout << std::numeric_limits<cpp_bin_float_100>::digits10 << std::endl;
20 
21    // We can use any C++ std lib function, lets print all the digits as well:
22    std::cout << std::setprecision(std::numeric_limits<cpp_bin_float_100>::max_digits10)
23       << log(b) << std::endl; // print log(2)
24 
25    // We can also use any function from Boost.Math:
26    std::cout << boost::math::tgamma(b) << std::endl;
27    // These even work when the argument is an expression template:
28    std::cout << boost::math::tgamma(b * b) << std::endl;
29 
30    // And since we have an extended exponent range we can generate some really large
31    // numbers here (4.0238726007709377354370243e+2564):
32    std::cout << boost::math::tgamma(cpp_bin_float_100(1000)) << std::endl;
33    return 0;
34 }
35 
36 //]
37