fix (kernel): fixed bug with smaller num_bits values in binary to alpha conversion

This commit is contained in:
antifallobst 2023-02-11 18:55:55 +01:00
parent 5b434d7264
commit a835ee6789
1 changed files with 2 additions and 1 deletions

View File

@ -112,7 +112,8 @@ void string_hex_64bit_to_alpha(string_t string, uint64_t value) {
void string_bin_to_alpha(string_t string, uint8_t num_bits, uint64_t value) {
char* buffer = (char*)string;
num_bits = MIN(num_bits, 64);
num_bits = MIN(num_bits, 64);
value <<= 64 - num_bits;
for (uint8_t i = 0; i < num_bits; i++) {
buffer[i] = ((value & (0x8000000000000000 >> i)) > 0) ? '1' : '0';
}