Mail Archives: djgpp/2001/10/12/11:30:48
> 2. a<<4.
>
> And here is my first question: will the result be 0x23 0x40
> (0x2340) on first and 0x41 0x20 (0x2041) on second machine (just
> contents of memory were shifted) or byte-order doesn't mean, and the
> result will be always 0x2340 (0x23 0x40 on first and 0x40 0x23 on
> second).
No, they'll be the same. C operators are defined in terms of the
*value* not the representation. 0x1234 << 4 is 0x2340, no matter how
the chip decides to store it.
> 3. Some boolean-logic operation: for example a & 0xFF00 - will it be
> always 0x1200 or 0x1200 on first and 0x3400 on second machine?
It will always be 0x1200.
> 4. And now really fool question - 0x12 0x34 and 0x34 0x12 - which one
> is big-endian and which is little-endian.
Little endian stores the least significant byte first ("little end
first"). Big endian is most significant byte first.
0x1234 is stored like this:
Address: 0 1
Little-endian: 0x34 0x12
Big-Endian: 0x12 0x34
0x12345678 is stored like this:
Address: 0 1 2 3
Little-endian: 0x78 0x56 0x34 0x12
Big-Endian: 0x12 0x34 0x56 0x78
- Raw text -