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

Home » Public Forums » archive » inversed Real
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
inversed Real [message #10921] Wed, 04 February 1998 00:00
Hans-Martin Latuske is currently offline  Hans-Martin Latuske
Messages: 1
Registered: February 1998
Junior Member
Hello,

I have to read REAL numbers (6 byte) from a data field using IDL. My
problem: In this field the order of the bytes of each real number is
inverted, which means lowest byte first.

here is my solution which is working, but in my opinion to long

************************************

pro d

filename=DIALOG_Pickfile(/READ,FILTER='*.img',PATH='./')
;read header
openr, 1, filename
hed=bytarr(4048)
readu, 1, hed
close, 1

;copy height scale factor
rn = hed(3291:3296)

;get exponent
ex = double(rn(0) - 129)
ex = 2.0^ex

;get mantissa
k =5
val=0.0
for i=1,39 do begin


b=ishft(128,-(i mod 8))
c=rn(k) and b

if c gt 0 then begin
val = val + 0.5^i
endif

if (((i+1) mod 8) eq 0) then k=k-1

endfor

;get sign
v=1.0
c = rn(0) and 128
if c > 0 then v=-1.0

; put everything together -> Heightscalefactor

r = v * ex * (1.0 + val)
if rn(5) eq 0 then r = 0.0

******************************************************

Is there somebody who nows a more sufficiant way to read this REAL
number?


Thanks

--
Hans-Martin Latuske
Institut fuer Experimentelle Physik
Otto-von-Guericke Universitaet Magdeburg
39102 Magdeburg
[Message index]
 
Read Message
Previous Topic: No tick at right end of axis
Next Topic: Re: Fun with CDF_ENCODE_EPOCH

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

Current Time: Wed Oct 08 16:01:21 PDT 2025

Total time taken to generate the page: 0.00508 seconds