little and big endian -- once more [message #15342] |
Wed, 12 May 1999 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Hi all,
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.
Thanks,
Martin.
; Extra attention to binary (f77 type) files:
; Set keywords for SWAP_IF_LITTLE_ENDIAN and SWAP_IF_BIG_ENDIAN
; depending on operating system
; do it only for read only opening
if not (keyword_set(write)) then begin
Swap_If_Big_Endian = (strupcase(!version.arch) eq 'X86')
Swap_If_Little_Endian = 1 - Swap_If_Big_Endian
endif
; debug uses little_endian function from Robert Mallozi
print,'#DEBUG: little_endian = ',little_endian()
help,Swap_If_Little_Endian,Swap_If_Big_Endian
--
|||||||||||||||\\\\\\\\\\\\\-------------------///////////// //|||||||||||||||
Martin Schultz, DEAS, Harvard University, 29 Oxford St., Pierce 109,
Cambridge, MA 02138 phone (617) 496 8318 fax (617) 495 4551
e-mail mgs@io.harvard.edu web http://www-as/people/staff/mgs/
|
|
|