Re: Wrap up question regarding use of bitfields in structures.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Akshay,
 
> Could anyone pls explain to me this behavior ?

I think it is best explained as GIGO.

Or as per ISO 14882 4.7.2:

If the destination type is unsigned, the resulting value is the least
unsigned integer congruent to the source integer (modulo 2^n where n is the
number of bits used to represent the unsigned type).

You can see the same kind of behavior by doing:

unsigned char c = 0x123456;

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux