summaryrefslogtreecommitdiff
path: root/AK/PrintfImplementation.h
diff options
context:
space:
mode:
authorConrad Pankoff <deoxxa@fknsrs.biz>2019-08-28 10:13:08 +1000
committerAndreas Kling <awesomekling@gmail.com>2019-08-28 06:43:04 +0200
commit970e0147f7f73ada908563be71159fdaba09f7f8 (patch)
treefad837c4ecbcea90406de66004907f95b89bf419 /AK/PrintfImplementation.h
parentb1763238d79a9831d2965f4c26b4d7dd51dd1422 (diff)
downloadserenity-970e0147f7f73ada908563be71159fdaba09f7f8.zip
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.
Diffstat (limited to 'AK/PrintfImplementation.h')
-rw-r--r--AK/PrintfImplementation.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index 3034bfa6f9..ff76889afd 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -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;