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

Re: little and big endian -- once more

Martin Schultz (mgs@io.harvard.edu) writes:

>  took me a while to realize that it is the machine architecture not
> the OS that determines the byte swapping -- in fact I needed to have IDL
> on linux (after using it on an SGI and with Windows) to figure that out
> ...  Anyway, I now devised the following test for byte swapping which is
> applied in my open_file routine and handles everything transparently.
> Please tell me if there are any other machine architectures that are big
> endian and what their !version.arch tag would be.

Here is a little function, Martin, that will make sure
your code works without having to track every machine
architecture down. Found it on my web page. :-)



FUNCTION Little_Endian

; Returns 1 if Little-Endian, returns 0 if Big-Endian.

  little_endian = (BYTE(1, 0, 1))[0]   
  RETURN, little_endian

David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155