debug_adaptor_snips.cpp 904 B

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