AK: Make printf %x actually work properly

When printing hex numbers, we were printing the wrong thing sometimes. This
was because we were dividing the digit to print by 15 instead of 16. Also,
dividing by 16 is the same as shifting four bits to the right, which is a
bit closer to our actual intention in this case, so let's use a shift
instead.
This commit is contained in:
Conrad Pankoff 2019-08-28 10:13:08 +10:00 committed by Andreas Kling
parent b1763238d7
commit 970e0147f7
Notes: sideshowbarker 2024-07-19 12:29:02 +09:00

View File

@ -18,7 +18,7 @@ template<typename PutChFunc, typename T>
int ret = 0;
int digits = 0;
for (T n = number; n > 0; n /= 0x0f)
for (T n = number; n > 0; n >>= 4)
++digits;
if (digits == 0)
digits = 1;