I have a number on which I perform a specific operation I want to make sure that the number is still divisible after the operation.
Let's say I have an integer x which is divisible by PAGE_S
does this produces an integer which is also divisible by PAGE_S ?
x^ ~(PAGE_S-1);
so (x % PAGE_S) == ( (x^ ~(PAGE_S-1)) % PAGE_S)
?
As far as I tested, it works, but I need to understand why...
p.s this is part of a code of translating virtual memory addresses to physical addresses