[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: little and big endian -- once more
- Subject: Re: little and big endian -- once more
- From: davidf(at)dfanning.com (David Fanning)
- Date: Wed, 12 May 1999 13:55:34 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <3739C486.92A23A8A@io.harvard.edu>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:14713
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. :-)
Cheers,
David
*****************************************************
FUNCTION Little_Endian
; Returns 1 if Little-Endian, returns 0 if Big-Endian.
little_endian = (BYTE(1, 0, 1))[0]
RETURN, little_endian
END
*****************************************************
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