Search code examples
c++128-bit

How to take input 128 bit unsigned integer in c++


I am new to c++. I want to take input a unsigned 128 bit integer using scanf and print it using printf. As I am new to c++ , I only know these two methods for input output. Can someone help me out?


Solution

  • You could use boost, but this library set must be installed yourself:

    #include <boost/multiprecision/cpp_int.hpp>
    #include <iostream>
    
    int main()
    {
       using namespace boost::multiprecision;
    
       uint128_t v = 0;
    
       std::cin >> v; // read 
       std::cout << v << std::endl; // write
    
       return 0;
    }