how would I convert a boost::multiprecision::int256_t type variable into a string for example if i have
string string1 = "12345";
boost::multiprecision::int256_t int1 (string1);
boost::multiprecision::int256_t int2 = int1 5
string string2;
// how do i making string equivalent to int2
CodePudding user response:
I think you just use the str()
method on the multiprecision number.
#include <iostream> // cout
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
int main()
{
std::string string1 = "12345";
boost::multiprecision::int256_t int1 (string1);
boost::multiprecision::int256_t int2 = int1 5;
std::string string2{ int2.str() };
std::cout << string2 << "\n";
}
// Outputs:
//
// 12350