aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2017-09-17 17:41:26 +0200
committerJ08nY2017-09-17 17:41:26 +0200
commitea5c5a34f0595746abfecffe846d38d9e85c36a0 (patch)
tree68aa64405f32348e48becdcfd44bbd4e621d2e77
parent2074700ba7a29e197bb7f1233cc0903131a93cf4 (diff)
downloadecgen-ea5c5a34f0595746abfecffe846d38d9e85c36a0.tar.gz
ecgen-ea5c5a34f0595746abfecffe846d38d9e85c36a0.tar.zst
ecgen-ea5c5a34f0595746abfecffe846d38d9e85c36a0.zip
-rw-r--r--src/util/bits.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/bits.c b/src/util/bits.c
index 6adae05..ab8180b 100644
--- a/src/util/bits.c
+++ b/src/util/bits.c
@@ -111,7 +111,7 @@ char *bits_to_hex(const bits_t *bits) {
char *result = try_calloc(BYTE_LEN(bits->bitlen) * 2 + 1);
// probably right pad with zeroes, as thats what is actually stored.
for (size_t i = 0; i < BYTE_LEN(bits->bitlen); ++i) {
- sprintf(result + (i * 2), "%x", bits->bits[i]);
+ sprintf(result + (i * 2), "%02x", bits->bits[i]);
}
return result;
}
@@ -119,7 +119,7 @@ char *bits_to_hex(const bits_t *bits) {
char *bits_to_bin(const bits_t *bits) {
char *result = try_calloc(bits->bitlen + 1);
for (size_t i = 0; i < bits->bitlen; ++i) {
- sprintf(result + i, "%u", GET_BIT(bits->bits, i));
+ sprintf(result + i, "%1u", GET_BIT(bits->bits, i));
}
return result;
}