I am study a source code, and i passed over this expression, I know what it does, but i want to know why the expression wasn't write in this form ((u32) 1 << (24)).
Thx
#typedef unsigned long u32
Those two expressions aren't the same: (assuming a 32 bit unsigned long)
the first one equals 0xff000000L while the second one is 0x01000000L.
The '-' (minus) operator has higher precedence than the << (shift left) operator.
0-1 causes wrap around to all bits 1. The expression could also be written as:
1) ~0<<24
2) 0xff<<24
and I'm sure many more ways exist to write this expression.
kind regards,
Jos