[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determining machine endian-ness



Mark Rivers (rivers@cars3.uchicago.edu) writes:

> Is there a way to determine whether the machine on which IDL is executing is
> big endian or little endian?  I am trying to read a data file which I know
> contains little-endian data.  I need to byte swap this data if IDL is running 
> on a big-endian machine, but not byte-swap if it is running on a little-endian
> machine.
> 
> It would be nice there were a field in !VERSION which contained this
> information.  Right now I am testing if !VERSION.ARCH eq 'x26', 'alpha', etc.
> There must be a better way.

I see in the IDL 5.1 on-line help that there are keywords
SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN to the
BYTEORDER procedure that allow conditional byte ordering depending 
upon the "endianness" of the machine IDL is running on. Sounds 
like just the ticket. :-)

Cheers,

David
-- 
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/