Skip to content

Instantly share code, notes, and snippets.

@dirvine
Created January 10, 2013 01:01
Show Gist options
  • Save dirvine/4498485 to your computer and use it in GitHub Desktop.
Save dirvine/4498485 to your computer and use it in GitHub Desktop.
Endian calculation (unrestricted union)
union Endian {
char c;
int i;
Endian(void) : i(1) { };
bool big(void) { return !!c; };
} endian;
cerr << (endian.big() ? "big" : "little");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment