I have the following sample code:
uint64_t x, y;
x = ~(0xF<<24);
y = ~(0xFF<<24);
The result would be:
x=0xffff
Because 0x0f << 24
is a positive number when viewed as an int
, it's sign-extended to a positive number, i.e. to 0x00000000_0f000000
(the underscore is just for readability, C does not support this syntax). This is then inverted into what you're seeing.
0xff << 24
on the other hand is negative, so it's sign-extended differently.