26 lines
526 B
C
26 lines
526 B
C
|
|
#include <stdint.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
void print_uint128(unsigned __int128 n) {
|
||
|
|
if (n == 0) {
|
||
|
|
printf("0\n");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
// A 128-bit number can have up to 39 decimal digits
|
||
|
|
char buffer[40];
|
||
|
|
int i = 0;
|
||
|
|
|
||
|
|
// Extract digits from right to left
|
||
|
|
while (n > 0) {
|
||
|
|
buffer[i++] = (n % 10) + '0'; // Convert math digit to character
|
||
|
|
n /= 10;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Print them in reverse order (left to right)
|
||
|
|
while (i > 0) {
|
||
|
|
putchar(buffer[--i]);
|
||
|
|
}
|
||
|
|
putchar('\n');
|
||
|
|
}
|