/** @return True if this machine has little endian byte order */Note: bit shifts and masking do not work because they should work the same way on every system.
bool isLittleEndian() {
int i = 1;
char *c = &i; // get the address of i
// true if the first byte contains the least significant byte
return (*c == 1);
}
Wednesday, July 2, 2008
Write a function that if run on different systems that tells the endianess of the system
Write a single function that if run on different systems that tells if it is little endian or big endian.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment