I found a type of variable that has a value of INTEGER (0…224 – 1). a guy who made the code decide to put a variable with type of uint32_t var; and put the result of this with 0xFFFFFF
how does this uint32_t & OxFFFFFF is able to handle the value of INTEGER (0…224 – 1) ?
As I understand, with masking 0xFFFFFF you make the value to be all positive (or?) but how does this thing work, I think I miss a concept here.
Masking with
0xffffffonly makes sure that the value that is stored never is outside the 0..2^24-1 range. Anything but the lower 24 bits are discarded.If you for example have the value
-1and mask it, it will end up as the value0xffffff. The value has changed, but now it’s inside the valid range.