Byte ordering schemes used by IDL platforms
Home
Register, Login   

     Tech Tips
 

Printable Version
Article Title: Byte ordering schemes used by IDL platforms
Article ID: 1804
Article Name: SYSTEM150
Last Updated: 10/29/2007 9:36:18 AM
Products: IDL
OS Platforms: Mac OS 8.x/9.x; UNIX OS; Alpha OpenVMS; WIN; Mac OS X; Linux-Intel; Linux-Alpha

Topic:

 

When reading data, created by a Sun Sparc machine, on a Windows XP machine it turns out to be nonsense? Why is this so?


Discussion:

This problem is the result of how machines store data. Sun Sparc machines are "Big Endian" machines, meaning that multiple byte integers are stored in memory beginning with the most significant byte. On the other hand, Windows XP machines are "Little Endian", meaning that multiple byte integers are stored in memory beginning with the least significant byte. To read data written by the Sun Sparc with the Windows XP machine or vice versa use the SWAP_ENDIAN function with either the SWAP_IF_LITTLE_ENDIAN or SWAP_IF_BIG_ENDIAN keyword.

Note
The keyword does not refer to the byte ordering of the input data, but to the byte ordering of the computer hardware.

If using the SWAP_ENDIAN function seems cumbersome then consider writing out the files using the XDR keyword. For example:

    ;Open a file for XDR output.
    OPENW, /XDR, 1, 'data.dat'

XDR is a machine independent format, that allows data written on one machine to be read transparently on any other machine.


PROCESSOR TYPEOPERATING SYSTEMBYTE ORDERING
Intel X86Linuxlittle-endian
Solaris X86little-endian
Windowslittle-endian
Macintoshlittle-endian
Motorola PowerPCMacintosh OS Xbig-endian
SGI R4000 and upIRIXbig-endian
Sun SparcSunOSbig-endian
Solarisbig-endian


Another easy way to determine the byte ordering for your system from an IDL prompt is to issue the command:

    print,'This machine is: ', byte(1,0)?'little endian':'big endian'

 
 Quick Links

   Contact a Representative
   Request Literature
   Events
   User Community
   Subscribe
 
 Product Information

   IDL
   ENVI
   ENVI EX
   IAS
   NITF for ArcGIS
   Professional Services
   Events & Training

Home   |   Company   |   Products & Services   |   Academic   |   Events & Training   |   Downloads   |   User Community   |   Support |   Site Map

Privacy Statement ©2008 ITT Visual Information Solutions