Home > Back-end >  Great god help look at this bit or operation. Thanks
Great god help look at this bit or operation. Thanks

Time:09-26

Int a=127;
Int b=127;
Int c=a | b;
C is equal to, please? The paper process
C=1? Why is this?
Int is 32-127 complement is 1000 0000 0000 0000 0000 0000 0000 0001
127 is 0000 0000 0000 0000 0000 0000 0111 1111
Two contrast is 1000 0000 0000 0000 0000 0000 0111 1111
Should be - 127 ah why output is a great god help solve below 1 o thank you

CodePudding user response:


So or 1, 32-1

CodePudding user response:

reference 1/f, love to eat fish ね こ response:

So or 32 1, namely 1

- 127
The original code 1000 0000 0000 0000 0000 0000 0111 1111
Radix-minus-one complement 1111 1111 1111 1111 1111 1111 1000 0000
Complement 1111 1111 1111 1111 1111 1111 1000 0001

127
The original code 0000 0000 0000 0000 0000 0000 0111 1111
Radix-minus-one complement 0000 0000 0000 0000 0000 0000 0111 1111
Complement 0000 0000 0000 0000 0000 0000 0111 1111


Complement 1111 1111 1111 1111 1111 1111 1000 0001
Complement 0000 0000 0000 0000 0000 0000 0111 1111
Or 1111 1111 1111 1111 1111 1111 1111 1111
The original code 1000 0000 0000 0000 0000 0000 0000 0001
With 0000 0000 0000 0000 0000 0000 0000 0001
Thank you, already understand, back to the original code or after a complement to take back to just add 1
Before I was in the back to the original code
  • Related