From c95d3c158e85f8d73b4629edd176015c27791fa5 Mon Sep 17 00:00:00 2001 From: RoguePotato Date: Tue, 25 Sep 2018 19:32:56 +0100 Subject: [PATCH] Fixed hex_to_string to display 'a' character properly. --- 22-malloc/libc/string.c | 2 +- 23-fixes/libc/string.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/22-malloc/libc/string.c b/22-malloc/libc/string.c index 9b8a6d3..d4c99be 100644 --- a/22-malloc/libc/string.c +++ b/22-malloc/libc/string.c @@ -29,7 +29,7 @@ void hex_to_ascii(int n, char str[]) { tmp = (n >> i) & 0xF; if (tmp == 0 && zeros == 0) continue; zeros = 1; - if (tmp > 0xA) append(str, tmp - 0xA + 'a'); + if (tmp >= 0xA) append(str, tmp - 0xA + 'a'); else append(str, tmp + '0'); } diff --git a/23-fixes/libc/string.c b/23-fixes/libc/string.c index 688f4a5..4c78284 100644 --- a/23-fixes/libc/string.c +++ b/23-fixes/libc/string.c @@ -29,7 +29,7 @@ void hex_to_ascii(int n, char str[]) { tmp = (n >> i) & 0xF; if (tmp == 0 && zeros == 0) continue; zeros = 1; - if (tmp > 0xA) append(str, tmp - 0xA + 'a'); + if (tmp >= 0xA) append(str, tmp - 0xA + 'a'); else append(str, tmp + '0'); }