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 #include <boost/multiprecision/cpp_dec_float.hpp> 7 #include <boost/multiprecision/debug_adaptor.hpp> 8 #include <iostream> 9 t1()10 void t1() 11 { 12 //[debug_adaptor_eg 13 //=#include <boost/multiprecision/debug_adaptor.hpp> 14 //=#include <boost/multiprecision/cpp_dec_float.hpp> 15 16 using namespace boost::multiprecision; 17 18 typedef number<debug_adaptor<cpp_dec_float<50> > > fp_type; 19 20 fp_type denom = 1; 21 fp_type sum = 1; 22 23 for(unsigned i = 2; i < 50; ++i) 24 { 25 denom *= i; 26 sum += 1 / denom; 27 } 28 29 std::cout << std::setprecision(std::numeric_limits<fp_type>::digits) << sum << std::endl; 30 //] 31 } 32 main()33 int main() 34 { 35 t1(); 36 return 0; 37 } 38 39 40 41