Skip to content

Instantly share code, notes, and snippets.

@hpcx82
Created July 23, 2011 06:05
Show Gist options
  • Save hpcx82/1101090 to your computer and use it in GitHub Desktop.
Save hpcx82/1101090 to your computer and use it in GitHub Desktop.
bool IsLittleEndian()
{
int code = 0x12345678;
char* pc = (char*)&code;
char a = (*pc);
char b = *(pc+1);
char c = *(pc+2);
char d = *(pc+3);
// 0x78 is the least significant byte,
// variable a is the value of lowest address byte
return a == 0x78;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment