fix (kernel): fixed bug with smaller num_bits values in binary to alpha conversion
This commit is contained in:
parent
5b434d7264
commit
a835ee6789
|
@ -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) {
|
void string_bin_to_alpha(string_t string, uint8_t num_bits, uint64_t value) {
|
||||||
char* buffer = (char*)string;
|
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++) {
|
for (uint8_t i = 0; i < num_bits; i++) {
|
||||||
buffer[i] = ((value & (0x8000000000000000 >> i)) > 0) ? '1' : '0';
|
buffer[i] = ((value & (0x8000000000000000 >> i)) > 0) ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue