Add method to print 128-bit integers in decimal format
pavelkryukov opened this issue · 5 comments
pavelkryukov commented
Currently 128 bit integers cannot be printed as decimal, only least significant 64 bits are exposed:
mipt-mips/simulator/infra/types.h
Line 52 in 3297118
Your task is to implement or copy-paste 128-bit print along with unit tests.
agrachiv commented
I already did it in some contest, if printing it by two halves is relevant solution. Where should be the unit-test folder? I didn't find any tests for all of the hiders in infra
folder.
pavelkryukov commented
What do you mean by 'printing by 2 halves'?
pavelkryukov commented
agrachiv commented
What do you mean by 'printing by 2 halves'?
Something like
void print128(uint128 number) {
if (number <= UINT64_MAX) {
print64( number);
} else {
uint128 leading = number / 10000000000000000000
uint64 following = number % 10000000000000000000
print64( leading);
print64( following);
}
}
pavelkryukov commented
That's hexadecimal, it's simple. Decimal is tricky,