Review bitwise operator

Complement value stored in the computer with

Examples :( original code in octets) represent the first sign bit, a numerical value 7 behind

Complement: Positive: The original code is the complement

           Negative: The original code symbol bits unchanged, the rest of you negate + 1

Number of positive bitwise: Members inverted -> complement becomes negative -> output, - (you negation + 1) -> - (original digital +1)

For example ~ 5: 0000 0000 0000 0000 0,000,000,000,000,101 (original code / complement) -> (you get trans) -> 1,111,111,111,111,111 1,111,111,111,111,010 (complement) -> (minus + (you negated +1)) -> - 0,000,000,000,000,000 0,000,000,000,000,110

Bitwise negative number: the rest of you change the sign bit inverted +1 complement code storage -> inverted become positive -> Direct Output -> - (original digital +1)

~ Ie negative (-5):

1,000,000,000,000,000 0,000,000,000,000,101 (original code) -> 1,111,111,111,111,111 1,111,111,111,111,010 (complement) -> (you negated only) 0000 0000 0000 0000 0000 000000000101-> positive direct output

Summary: ~ n = - (n + 1)

Guess you like

Origin www.cnblogs.com/code-fun/p/11460683.html