In C
I could the Endianess
of the machine by the following method. how would I get using a python
or Java
program?. In Java, char is 2-bytes
unlike C
where it is 1-byte
. I think it might not be possible with python
since it is a dynamic language
, but I could be wrong
bool isLittleEndian()
{
// 16 bit value, represented as 0x0100 on Intel, and 0x0001 else
short pattern = 0x0001;
// access first byte, will be 1 on Intel, and 0 else
return *(char*) &pattern == 0x01;
}