mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
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:
parent
b1763238d7
commit
970e0147f7
Notes:
sideshowbarker
2024-07-19 12:29:02 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/970e0147f7f Pull-request: https://github.com/SerenityOS/serenity/pull/496
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user