Re: How to output a big integer:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Tsang wrote:
The following code doesn't compile under both g++-4.4 and g++-4.5

#include <iostream>

int main() {
        __uint128_t x = 0;
        std::cout << x << '\n';
}


How to output x in the code?

ostream& operator<< (ostream &s, __uint128_t n)
{
  char c = '0' + (n % 10);
  n /= 10;
  if (n)
    s << n;
  return s << c;
}

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux