Created
August 31, 2013 22:54
-
-
Save ylegall/6401162 to your computer and use it in GitHub Desktop.
Determines whether a computer is big-endian or little-endian.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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