Tilde and order of operations
Posted 21 October 2011 - 07:04 PM
0010 -> 1101
but when I test it I really don't know what I'm looking at...
Also, if anyone knows, what is the complete oder of operations to include bitwise operators? I'm going off of this:
<, >, <=, >=
*, /, mod, div
Posted 21 October 2011 - 07:43 PM
1) Start from the right side. The right-most bit is bit 0, then bit 1, etc.
2) If bit N is b[N] (and either 0 or 1), then going from right-to-left, add b[N] * 2^N.
When you're done, the resulting number is the same number the bit string represents. So let's say you have the value 3. In binary, that's 00000011. So ~3 = 11111100. Converting that to decimal, you get 252. So ~3=252.
for single-bytes, you may notice that ~X = 255-X, but for multi-byte values that doesn't hold.
Posted 21 October 2011 - 10:07 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users