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

Re: Determining machine endian-ness

In article <EvBpCE.Hru@midway.uchicago.edu>,
	rivers@cars3.uchicago.edu (Mark Rivers) 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 think this should do it:

    LITTLE_ENDIAN = (BYTE (1, 0, 1))[0]

       PRINT, "I'm little endian"

Robert S. Mallozzi