comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » little and big endian -- once more
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
little and big endian -- once more [message #15342] Wed, 12 May 1999 00:00 Go to previous message
Martin Schultz is currently offline  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/
[Message index]
 
Read Message
Read Message
Previous Topic: coherence test implementation
Next Topic: Re: coherence.pro re-re-post (ignore previous re-post)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 15:28:28 PDT 2025

Total time taken to generate the page: 1.43845 seconds