digitalmars.D.learn - Best way to Identify Endianness?
- Jesse Phillips (9/9) Oct 04 2012 Just thought I would check if there was a Phobos method available
- =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= (8/17) Oct 04 2012 version (LittleEndian) { ... }
- bearophile (6/7) Oct 05 2012 Take a look here:
Just thought I would check if there was a Phobos method available
or if others had pointers. I'm currently just using a function:
bool bigEndian() {
int i = 1;
return *cast(ubyte*)&i == 0;
}
Any other options?
I'm using this for UUID <-> GUID conversion. GUID uses Native
ordering for 3 groupings.
Oct 04 2012
On 05-10-2012 07:49, Jesse Phillips wrote:
Just thought I would check if there was a Phobos method available or if
others had pointers. I'm currently just using a function:
bool bigEndian() {
int i = 1;
return *cast(ubyte*)&i == 0;
}
Any other options?
I'm using this for UUID <-> GUID conversion. GUID uses Native ordering
for 3 groupings.
version (LittleEndian) { ... }
else version (BigEndian) { ... }
http://dlang.org/version.html
--
Alex Rønne Petersen
alex lycus.org
http://lycus.org
Oct 04 2012
Jesse Phillips:Any other options?Take a look here: http://dlang.org/phobos/std_system.html Similar handy things are meant to be in Phobos. Bye, bearophile
Oct 05 2012









=?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <alex lycus.org> 