Or the complement bit

When looking at the code-bit processing you will often see :( variable) with (their complement) to do bits or , that is, x | -x

The result of the process is this: get a value of y, y start from the lowest number of consecutive 0, then x is the same.

E.g:

1)

1010 1011 1100 1101   --> x

0101 0100 0011 0011   --> -x

1111 1111 1111 1111   --> x|-x

2)

1010 1011 1100 1000   --> x

0101 0100 0011 1000   --> -x

1111 1111 1111 1000  --> x|-x

3)

1010 1000 0000 0000   --> x

0101 1000 0000 0000   --> -x

1111 1000 0000 0000  --> x|-x

Have this effect due to the definition of complement - adding all 1 bits inverted, and this took from a lowest-order bit first stretch of consecutive 1's all become 0 (since the carry), just the result of this 0 original code 0 in the same, or when the incumbent is still zero.

Reproduced in: https: //www.cnblogs.com/mmars/archive/2013/05/13/3076062.html

Guess you like

Origin blog.csdn.net/weixin_33874713/article/details/92973287
Bit
BIT