In a big-endian machine, if I have a long variable and cast it to a char, does the language specification guarantees I will get the least significant bits after the cast?
In other words:
long a = 50;
char b = (char)a;
assert(b == 50); /* Is it true? */
I know this is true for little-endian machines, but what about big-endian?
Since
charmust be able to accommodate values up to at least 127, the result in this case must be 50.