This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to output a big integer:
- From: Andrew Haley <aph at redhat dot com>
- To: Michael Tsang <miklcct at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 12 Nov 2009 10:58:03 +0000
- Subject: Re: How to output a big integer:
- References: <200911121732.13727.miklcct@gmail.com>
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.