P
pete
BTW, does C make any guarantees that the code works both endianness? I
have worked with compilers where shifting didn't do what I expected
because the machine was little endian.
If you have a two byte int and you shift it to the right,
the low order bit of the high order byte goes into the low order byte.
That happens regardless of which byte is high order.
That's what's supposed to happen.
The byte with the higher address isn't inherently
high order or low order, as far as C is concerned.
You can write portable code to
print the values of all the bytes in an int object,
from lowest to highest address and/or from highest to lowest.
This code will use the address of the int object.
You can write portable C code to print the values
of all of the bytes of an int value which have value bits,
in order from least significant to most significant
or the other way around.
This code will not use the address of the object
and will be able to operate on constant expressions.