I want to print integer value that converted from hexadecimal value but i only could print hexadecimal value.
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
cpp_int dsa("0xFFFFFFFFFFFFFFFF");
cpp_int daa("9223372036854775807");
daa = ((daa * 64) + daa);
cout << std::hex<<dsa <<std::showbase<< endl;
cout <<dsa << endl;
cout <<daa << endl;
cout <<(int)daa << endl;
cout <<(int128_t)daa << endl;
output
ffffffffffffffff
0xffffffffffffffff
0x207fffffffffffffbf
0x7fffffff
0x207fffffffffffffbf
How can i print max value of 128 bit type of integer ?
You should use std::numeric_limits
to get the max value, because that's its purpose.
Your formatting issue is independent of your actual question.
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits>
int main()
{
auto max = std::numeric_limits<boost::multiprecision::int128_t>::max();
std::cout << max << std::endl;
}
User contributions licensed under CC BY-SA 3.0