I have the following code snippet:
lower_mask = 0x7FFFFFFF
upper_mask = bitwNot(lower_mask)
"upper_mask" is NA after running it. I don't know why. If this was an overflow case it would be pretty strange since NOT operator should not overflow and just flip the bits. Can you please explain me what is happening and how can I fix it ? Thanks.
The bitwise not of 0x7fffffff is 0x8000000. Unfortunately for your purposes, that's the encoding used for the integer NA.
R only supports 2^32 - 1 non-NA values, from -.Machine$integer.max to +.Machine$integer.max. In hex, those are 0x80000001 to 0x7fffffff.