By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,445 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,445 IT Pros & Developers. It's quick & easy.

Bitwise shift help please?

P: n/a
Hi,

can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?

Kosta

Mar 14 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 13 Mar 2007 20:05:48 -0700, kn******@gmail.com wrote:
>Hi,

can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?

Kosta
unsigned int x = 0x10;

x >1;

This statement computes the value of the expression (0x08) and then
discards it.

x >>= 1;

This statement computes the same value but assigns the result to x.
Remove del for email
Mar 14 '07 #2

P: n/a
In other words x>>1; does not alter x?( Answering myself: Off course
it makes perfect sense) Thanks

On Mar 14, 1:40 pm, Barry Schwarz <schwa...@doezl.netwrote:
On 13 Mar 2007 20:05:48 -0700, knser...@gmail.com wrote:
Hi,
can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?
Kosta

unsigned int x = 0x10;

x >1;been doing is to copy links to these problem

This statement computes the value of the expression (0x08) and then
discards it.

x >>= 1;

This statement computes the same value but assigns the result to x.

Remove del for email

Mar 14 '07 #3

P: n/a
On Mar 14, 8:05 am, knser...@gmail.com wrote:
Hi,

can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?

Kosta
Hi Kosta,
What exactly you have in mind when you attribute the difference
between >and >>= to precedence?
Can you please elaborate your querry, even though you have got the
answers from the above two responses?
Thanks,

Mar 14 '07 #4

P: n/a
Rahul wrote:
On Mar 14, 8:05 am, knser...@gmail.com wrote:
Hi,

can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?

Kosta

Hi Kosta,
What exactly you have in mind when you attribute the difference
between >and >>= to precedence?
Can you please elaborate your querry, even though you have got the
answers from the above two responses?
Thanks,
The two statements are not directly comparable, since they're not the
same.

Mar 14 '07 #5

P: n/a
kn******@gmail.com wrote:
Hi,

can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ?
The same as the difference between the addition operator +
and the add-and-assign operator +=.
Is it only
precidence?
No, it's more than just precEdence. Both operators perform
a shift (or an add, or whatever), but only the "-and-assign" forms
also do an assignment.

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.