Bit Operations

Top 

~    Usage: ~ie

    One's complement of the value ie. The expression value contains ones in

    all those bits, in which ie contains 0, and contains 0 in all

    those bits, in which ie contains ones.

    Example:

      opposite = ~mask;

>>   Usage: ie1 >> ie2

    The right ie2 shift of the ie1 binary form.

    The shift may be arithmetic (that is, the bits cleared from the left

    assume the value of the sign bit) for the signed numbers and

    logical for the unsigned numbers (the bits cleared from the left are

    filled with zeroes).

    Example:

      x = x >> 3;

<<   Usage: ie1 << ie2

    The left ie2 bit left of the ie2 binary form.

    The bits cleared from the right are filled with zeroes.

    Example:

      fourx = x << 2;

&    Usage: ie1 & ie2

    The bit-wise AND operation of the ie1 and ie2 binary forms. The expression

    value assumes 1 in all those bits, in which both ie1 and ie2 contain

    1, and assumes 0 in all other bits.

 

      flag = ((x & mask) != 0);

|    Usage: ie1 | ie2

    The bit-wise OR operation of the ie1 and ie2 binary forms. The expression

    value assumes 1 in all those bits, in which either ie1 or ie2 contain

    1, and assumes 0 in all other bits.

    Example:

      attrsum = attr1 | attr2;

^    Usage: ie1 ^ ie2

    The bit-wise exclusive OR operation of the ie1 and ie2 binary forms.

    The expression value contains 1 in all those bits, in which ie1 and

    ie2 contain different binary values, and the expression value

    contains 0 in all other bits.

    Example:

      diffbits = x ^ y;