Some code from the reflector

byte[] expr_239_cp_0 = this.buf; int expr_239_cp_1 = num; expr_239_cp_0[expr_239_cp_1] |= 1; 

What operation |=1 ?

  • setting the last bit of the number in the unit - Grundy

1 answer 1

Operator | = - performs a bitwise OR operation.

Record

 x |= 1 

is equivalent to

 x = x | 1 

When used with parameter 1, the number on the left is set to the last bit to 1.

Since this is a bitwise operation, the operands for it are sets of bits, which means that the record 100 | 192 100 | 192 will be performed as follows

 01100100 11000000 -------- 11100100 

And it will be equal to 228 .

  • Got it. There is also such: expr_101C_cp_0 [expr_101C_cp_1] | = 192; Is it possible to set the bit to 192? - jshapen
  • one
    @jshapen, this is a bitwise operation. that is, operands for it are a set of bits - Grundy
  • one
    @jshapen, added an example in response - Grundy