Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Promotion and assignment

Reply
Thread Tools

Promotion and assignment

 
 
Tomás Ó hÉilidhe
Guest
Posts: n/a
 
      07-09-2008

Take the following:

char unsigned i = 0, j = 5;
...
...
i &= j;

I'd like to see what happens in the last statement. If it were
identical to:

i = i & j;

then the follwoing would happen:
* On the right-hand side, both i and j would be promoted to either
signed int or unsigned int
* The bitwise AND would be performed on these two int's
* Then the result would be converted to an unsigned char to be stored
in i

Does exactly the same thing happen with i &= j?
 
Reply With Quote
 
 
 
 
vippstar@gmail.com
Guest
Posts: n/a
 
      07-09-2008
On Jul 9, 4:11 pm, Tomás Ó hÉilidhe <(E-Mail Removed)> wrote:
> Take the following:
>
> char unsigned i = 0, j = 5;
> ...
> ...
> i &= j;
>
> I'd like to see what happens in the last statement. If it were
> identical to:
>
> i = i & j;
>
> then the follwoing would happen:
> * On the right-hand side, both i and j would be promoted to either
> signed int or unsigned int

Don't you mean int unsigned?

> * The bitwise AND would be performed on these two int's
> * Then the result would be converted to an unsigned char to be stored
> in i
>
> Does exactly the same thing happen with i &= j?

Yes, for the long answer see Mr Sosmans post.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assignment operator self-assignment check Chris C++ 34 09-26-2006 04:26 AM
Augument assignment versus regular assignment nagy Python 36 07-20-2006 07:24 PM
ASP.NET, source safe and promotion levels Jon Paul Jones ASP .Net 8 02-08-2005 09:20 PM
Data Recovery Book and Online Business Promotion, Products Sales Promotion, Search Engine Optimization and Online Data Recovery Training services Author Tarun Tyagi Cisco 0 12-15-2004 01:52 AM
The promotion code "MSUU4C8E3475" is not a valid promotion code Sam-Hong Kong MCDST 2 03-04-2004 06:47 PM



Advertisments