Connecting Tech Pros Worldwide Forums | Help | Site Map

Bitwise shift help please?

knservis@gmail.com
Guest
 
Posts: n/a
#1: Mar 14 '07
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


Barry Schwarz
Guest
 
Posts: n/a
#2: Mar 14 '07

re: Bitwise shift help please?


On 13 Mar 2007 20:05:48 -0700, knservis@gmail.com wrote:
Quote:
>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
Farmer
Guest
 
Posts: n/a
#3: Mar 14 '07

re: Bitwise shift help please?


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:
Quote:
On 13 Mar 2007 20:05:48 -0700, knser...@gmail.com wrote:
>
Quote:
Hi,
>
Quote:
can somebody please explain to me what is the difference between right
(or left) shift >and right shift assign >>= ? Is it only
precidence?
>
Quote:
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

Rahul
Guest
 
Posts: n/a
#4: Mar 14 '07

re: Bitwise shift help please?


On Mar 14, 8:05 am, knser...@gmail.com wrote:
Quote:
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,

santosh
Guest
 
Posts: n/a
#5: Mar 14 '07

re: Bitwise shift help please?


Rahul wrote:
Quote:
On Mar 14, 8:05 am, knser...@gmail.com wrote:
Quote:
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.

Eric Sosman
Guest
 
Posts: n/a
#6: Mar 14 '07

re: Bitwise shift help please?


knservis@gmail.com wrote:
Quote:
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 +=.
Quote:
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
esosman@acm-dot-org.invalid
Closed Thread