[postgis-devel] Determining Endianess

David Blasby dblasby at refractions.net
Mon Feb 9 09:26:52 PST 2004


Here's a piece of code that directly tests the endian of the machine.
Basically, it looks at how the number 1 is stored.  In the 4 byte int, 
if its NDR, it will be in the 1st byte.  If its XDR, it'll be in the 
last byte.

	int test = 1;

	if ( (((char *)(&test))[0]) == 1)
	{
		//NDR
	}
	else
	{
		//XDR
	}




More information about the postgis-devel mailing list