# what do these operations do?

• 01-29-2005
what do these operations do?
I am sorry if this is a stupid question but I have looked around and can not find the answer anywhere.

What do these two operations do?

a |= b

and

a=a>>1
• 01-29-2005
quzah
Read the Bitwise Operation FAQ. All the information you need is already written up there.

Quzah.
• 01-29-2005
Krak
Quote:

I am sorry if this is a stupid question but I have looked around and can not find the answer anywhere.

What do these two operations do?

a |= b

and

a=a>>1

Those are bitwise operations. The first adds two variables or constants with bitwise OR, and the second shifts a value a certain number of bits. If you don't know how to read binary code, then they're rather useless to you.

Say a=3 and b=5

Code:

```//Not actually code, but whatever.  0011 +0101  //Add using bitwise OR =0111 //Our result is 7.```
And the second operation would shift A's bits over 1 place to the right.

0011 >> 1 = 0001
So 3>>1 = 1.
• 01-29-2005
Thantos
Quote:

The first adds two variables or constants with bitwise OR
Very poor choice of words here. OR is not addition, as such it doesn't "add" them together.
• 01-29-2005
Krak
Quote:

Originally Posted by Thantos
Very poor choice of words here. OR is not addition, as such it doesn't "add" them together.

True..I kinda like to think of it as "adding with OR"...rather than calling it "OR'ing" them together, eh? ;)