fix get bits

This commit is contained in:
nganhkhoa 2024-08-29 15:22:42 +07:00
parent 9cdf9f0ff5
commit 88b79bccb9

View File

@ -31,8 +31,7 @@ uint32_t get_bits(uint32_t value, uint32_t from, uint32_t to) {
return (value & (1 << from)) != 0;
}
int32_t mask = ~(1U << (to - from + 1));
return (value & mask) >> from;
return (value << (31 - to)) >> (from + (31 - to));
}
int is_bit_set(uint32_t value, uint32_t at) {