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

Home » Public Forums » archive » Re: Double-Precision Byte Swap
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: Double-Precision Byte Swap [message #11595 is a reply to message #11588] Tue, 28 April 1998 00:00 Go to previous message
Peter Mason is currently offline  Peter Mason
Messages: 145
Registered: June 1996
Senior Member
On 28 Apr 1998, R. Kyle Justice wrote:
> Using PV-Wave in UNIX, is there a way to read
> double-precision floating point data generated
> on a PC?
> I think I need something something similar to
> the BYTEORDER procedure, but I need to (or do I?)
> swap 8 instead of 4 bytes.

Assuming that the data are IEEE double-precision (almost certainly), yes, you
just need to reverse the order of each number's 8 bytes.
(But note that if it's Digital Unix that you're using then you should NOT
re-order.)

I don't use PV-Wave, but here's a little IDL routine for the job:
;==================================
; Reverse the byte order of a whatever
pro byterev,v
j=size(v) &nj=n_elements(j) &t=j(nj-2) &n=j(nj-1)
if (t le 1) or (t ge 7) then return ;undefined, or inappropriate type
case t of
2:byteorder,v,/sswap ;short
3:byteorder,v,/lswap ;long
4:byteorder,v,/lswap ;float
5:begin &for i=0L,n-1L do v(i)=double(rotate(byte(v(i),0,8),2),0) &end ;double
6:byteorder,v,/lswap ;complex (it works, too!)
endcase
return
end
;==================================


Peter Mason
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Newbie-Questions: PV-WAVE
Next Topic: Re: IDL5 License Manager on DEC UNIX 4.0d

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

Current Time: Sat Oct 11 23:05:26 PDT 2025

Total time taken to generate the page: 0.64064 seconds