user2936723
user2936723

Reputation: 19

What does ">> 3" mean? Is it a redirection of some kind?

I am attempting to figure out what

 >> 3 

does in the code shown below. Is >> a redirect and if so, then what is 3? Can someone help?

#define BYTESIZE(bitsize)       ((bitsize + 7) >> 3)

Upvotes: 0

Views: 370

Answers (1)

Brian A. Henning
Brian A. Henning

Reputation: 1511

>> is the right shift operator. Right-shift takes a binary value and shifts it right by the right-hand operand. For example:

0100 >> 1 == 0010
00010000 >> 4 == 00000001

In decimal terms, this is the same as dividing by powers of two. >> 1 divides by two, >> 2 divides by four, >> 3 divides by 8, etc.

Upvotes: 5

Related Questions