#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
I take it as: fill register sized unsigned int with ones, then shake off MSB, obtaining maximum value for signed int. Is it correct? Also, the reason why they are doing it such way completely evades me, please enlighten.
You may rewrite this as
#define NP_MAXREADY (((~0u)<<1)>>1)
then you'd notice that the inner shift operation is completely useless, since its only effect is to shift out the highest order bit
#define NP_MAXREADY ((~0u)>>1)
which in turn is nothing than
#define NP_MAXREADY (UINT_MAX/2)
Other than stated in another answer, this is not INT_MAX
, since first of all this one here is an unsigned
, so the type is different. Then the representation of signed
versus unsigned
may have padding bits, so you never can be sure that these two have the same value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With