Skip to content

Instantly share code, notes, and snippets.

@ylegall
Created August 31, 2013 22:54
Show Gist options
  • Save ylegall/6401162 to your computer and use it in GitHub Desktop.
Save ylegall/6401162 to your computer and use it in GitHub Desktop.
Determines whether a computer is big-endian or little-endian.
import std.stdio;
auto isLittleEndian() {
int i = 0x11223344;
byte* b = cast(byte*)&i;
return b[0] == 0x44;
}
void main() {
if (isLittleEndian()) writeln("little endian");
else writeln("big endian");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment