1 ///////////////////////////////////////////////////////////////
2 // Copyright 2015 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
6 #include <boost/multiprecision/cpp_int.hpp>
15 In this simple example, we'll import/export the bits of a cpp_int
16 to a vector of 8-bit unsigned values:
19 #include <boost/multiprecision/cpp_int.hpp>
28 using boost::multiprecision::cpp_int;
29 // Create a cpp_int with just a couple of bits set:
31 bit_set(i, 5000); // set the 5000'th bit
34 // export into 8-bit unsigned values, most significant bit first:
35 std::vector<unsigned char> v;
36 export_bits(i, std::back_inserter(v), 8);
37 // import back again, and check for equality:
39 import_bits(j, v.begin(), v.end());