Re: Determining machine endian-ness [message #12129] |
Thu, 02 July 1998 00:00 |
callen
Messages: 5 Registered: October 1996
|
Junior Member |
|
|
> With IDL 4.0+, !VERSION tells you if your operating system is UNIX or WIN32. I
> would use this to determine if I need to byte-swap on some occassions. However,
This can't be a good idea, as IDL runs under Linux and FreeBSD on Intel boxes.
-- Charles Allen -- callen@bga.com --
|
|
|
Re: Determining machine endian-ness [message #12136 is a reply to message #12129] |
Thu, 02 July 1998 00:00  |
Kelly Dean
Messages: 92 Registered: March 1997
|
Member |
|
|
I check a value in my data that is normally constant. If this value is too big, I
byte-swap.
With IDL 4.0+, !VERSION tells you if your operating system is UNIX or WIN32. I
would use this to determine if I need to byte-swap on some occassions. However,
some people that use my stuff still are using IDL 3.6 - so I stick with checking a
number in the data for most of the IDL code I share.
Kelly
Mark Rivers wrote:
> 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.
>
> ____________________________________________________________
> Mark Rivers (773) 702-2279 (office)
> CARS (773) 702-9951 (secretary)
> Univ. of Chicago (773) 702-5454 (FAX)
> 5640 S. Ellis Ave. (708) 922-0499 (home)
> Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)
>
> or:
> Argonne National Laboratory (630) 252-0422 (office)
> Building 434A (630) 252-0405 (lab)
> 9700 South Cass Avenue (630) 252-1713 (beamline)
> Argonne, IL 60439 (630) 252-0443 (FAX)
|
|
|
Re: Determining machine endian-ness [message #12137 is a reply to message #12129] |
Thu, 02 July 1998 00:00  |
pit
Messages: 92 Registered: January 1996
|
Member |
|
|
In article <6nen9j$s9s$1@nnrp1.dejanews.com>,
menakkis@my-dejanews.com writes:
> Mark Rivers (rivers@cars3.uchicago.edu) asked:
>>> Is there a way to determine whether the machine on which IDL is executing is
>>> big endian or little endian?
>
> And David Fanning (davidf@dfanning.com) replied:
>> I see in the IDL 5.1 on-line help that there are keywords
>> SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN to the
>> BYTEORDER procedure that allow conditional byte ordering depending
>> upon the "endianness" of the machine IDL is running on. Sounds
>> like just the ticket. :-)
>
> Even more conveniently, in IDL 5.1 the OPEN routine (now) takes keywords
> SWAP_ENDIAN, SWAP_IF_LITTLE_ENDIAN and SWAP_IF_BIG_ENDIAN. These pertain to
> the computer running IDL, not the file. Presumably they make READU/WRITEU
> (and ASSOC?) smart about byte reordering. Anyone tried them yet?
Unfortunately, both ways are no option for us, as we have to be backward
compatible (some of our HP's still run 3.0.....).
But the solution of Robert works fine :-)
Peter
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Peter "Pit" Suetterlin http://www.uni-sw.gwdg.de/~pit
Universitaets-Sternwarte Goettingen
Tel.: +49 551 39-5048 pit@uni-sw.gwdg.de
-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * --
Come and see the stars! http://www.kis.uni-freiburg.de/~ps/SFB
Sternfreunde Breisgau e.V. Tel.: +49 7641 3492
____________________________________________________________ ______________
|
|
|
Re: Determining machine endian-ness [message #12140 is a reply to message #12129] |
Thu, 02 July 1998 00:00  |
menakkis
Messages: 37 Registered: June 1998
|
Member |
|
|
Mark Rivers (rivers@cars3.uchicago.edu) asked:
>> Is there a way to determine whether the machine on which IDL is executing is
>> big endian or little endian?
And David Fanning (davidf@dfanning.com) replied:
> I see in the IDL 5.1 on-line help that there are keywords
> SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN to the
> BYTEORDER procedure that allow conditional byte ordering depending
> upon the "endianness" of the machine IDL is running on. Sounds
> like just the ticket. :-)
Even more conveniently, in IDL 5.1 the OPEN routine (now) takes keywords
SWAP_ENDIAN, SWAP_IF_LITTLE_ENDIAN and SWAP_IF_BIG_ENDIAN. These pertain to
the computer running IDL, not the file. Presumably they make READU/WRITEU
(and ASSOC?) smart about byte reordering. Anyone tried them yet?
Cheers
Peter Mason
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
|
|
|
Re: Determining machine endian-ness [message #12143 is a reply to message #12129] |
Wed, 01 July 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Mark Rivers (rivers@cars3.uchicago.edu) 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 see in the IDL 5.1 on-line help that there are keywords
SWAP_IF_BIG_ENDIAN and SWAP_IF_LITTLE_ENDIAN to the
BYTEORDER procedure that allow conditional byte ordering depending
upon the "endianness" of the machine IDL is running on. Sounds
like just the ticket. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Determining machine endian-ness [message #12144 is a reply to message #12143] |
Wed, 01 July 1998 00:00  |
mallors
Messages: 76 Registered: November 1997
|
Member |
|
|
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.
>
Hi,
I think this should do it:
LITTLE_ENDIAN = (BYTE (1, 0, 1))[0]
IF (LITTLE_ENDIAN) THEN $
PRINT, "I'm little endian"
--
Robert S. Mallozzi
http://cspar.uah.edu/~mallozzir/
|
|
|