1 /////////////////////////////////////////////////////////////// 2 // Copyright 2011 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_dec_float_eg 7 #include <boost/multiprecision/cpp_dec_float.hpp> 8 #include <boost/math/special_functions/gamma.hpp> 9 #include <iostream> 10 main()11int main() 12 { 13 using namespace boost::multiprecision; 14 15 // Operations at fixed precision and full numeric_limits support: 16 cpp_dec_float_100 b = 2; 17 std::cout << std::numeric_limits<cpp_dec_float_100>::digits << std::endl; 18 // Note that digits10 is the same as digits, since we're base 10! : 19 std::cout << std::numeric_limits<cpp_dec_float_100>::digits10 << std::endl; 20 // We can use any C++ std lib function, lets print all the digits as well: 21 std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_100>::max_digits10) 22 << log(b) << std::endl; // print log(2) 23 // We can also use any function from Boost.Math: 24 std::cout << boost::math::tgamma(b) << std::endl; 25 // These even work when the argument is an expression template: 26 std::cout << boost::math::tgamma(b * b) << std::endl; 27 // And since we have an extended exponent range we can generate some really large 28 // numbers here (4.0238726007709377354370243e+2564): 29 std::cout << boost::math::tgamma(cpp_dec_float_100(1000)) << std::endl; 30 return 0; 31 } 32 //] 33 34