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

Home » Public Forums » archive » Re: Fortran unformatted data: Big or little endian
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Fortran unformatted data: Big or little endian [message #34951 is a reply to message #34948] Wed, 30 April 2003 08:05 Go to previous messageGo to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
David Fanning <david@dfanning.com> writes:

> Michael Schroeter (schroeter@muk.uni-hannover.de) writes:

>> and it works (up to now ;-)).

> I suspect it works *most* of the time. I don't see anything
> in there to *cause* the error. :-)

> You can certainly read data any way you like. It's not
> until you try to make *sense* of the data that you are
> likely to run into trouble. In your case, you might try
> reading a known data value from the file. It that value
> is total nonsense (your were expecting 45 and you get
> -20435), then you could "throw" an error, rewind the file,
> and read the data again with the SWAP_ENDIAN keyword set.

My experience has been that if one reads in floating point data with the wrong
byte-order, not only is the result garbage, but that one ends up with some
extremely large numbers, both positive and negative. For example, I reversed
the byte-order of an ordinary array, and ended up with an array with values of
2.70437e+38 and -1.90746e+38. One can use this to augment the procedure you
already have, by checking for values beyond a (generously defined) reasonable
range. In a sense, this is the same idea as David's, extended to where you may
not know what the exact value is that you expect, but you can recognize a
ridiculous value when you see one.

Cheers,

Bill Thompson
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fortran unformatted data: Big or little endian
Next Topic: Re: WIDGET_TEXT - HOW TO NOT CHANGE VALUE OF TEXT WHILE EDITING FIELD?

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

Current Time: Fri Oct 10 03:53:03 PDT 2025

Total time taken to generate the page: 3.20038 seconds