}
void os::print_formatted(const char* format, std::uint64_t val) {
os::assert(format[0] == '}', "Format string unsupported. TODO.");
- bool printed = false;
- os::print("0x");
- for (int i = 60; i >= 0; i -= 4) {
- const int v = (val >> i) & 0xF;
- if (printed || v != 0) {
- os::printc(v < 10 ? v + '0' : v - 10 + 'a');
- printed = true;
- }
+ char data[20];
+ char* curr = data + 19;
+ while (val != 0) {
+ *curr = val % 10 + '0';
+ val /= 10;
+ curr--;
}
- if (!printed) {
+ curr++;
+ if (curr == data + 20) {
os::printc('0');
+ } else while (curr < data + 20) {
+ os::printc(*curr++);
}
}
void os::print_formatted(const char* format, std::int64_t val) {