In C
I could the Endianess
of the machine by the following method. how would I get using a python
or Java
program?. In Ja
The (byte)
cast of short
is defined in both Java and C to return the "little" end of the short
, regardless of the endianness of the processor. And >>
is defined to shift from "big" end to "little" end (and <<
the opposite), regardless of the endianness of the processor. Likewise +
, -
, *
, /
, et al, are all defined to be independent of processor endianness.
So no sequence of operations in Java or C will detect endianness. What is required is some sort of "alias" of one size value on top of another (such as taking the address of an int
and casting to char*
), but Java does not have any way to do this.