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

Home » Public Forums » archive » Re: converting 8 bytes to a double
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: converting 8 bytes to a double [message #2535 is a reply to message #2504] Thu, 28 July 1994 09:36 Go to previous message
sterner is currently offline  sterner
Messages: 106
Registered: February 1991
Senior Member
stl@sma.ch (Stephen Strebel) writes:

> Hi again,

> sorry about that. COnverting 4 bytes to a long (as in the lasting
> posting) isn't really what I wanted to find out about. I really need to
> convert 8 bytes into a double.

> Any ideas? Or any libraries that already do this?

What you want to do is called field extraction and is discussed
in Chapter 4 of the IDL User's Guide in the secion on
Type Conversion Functions.

If you have a byte array b you can extract doubles from it as follows:

d = double(b,s,n)

where s is the starting element in array b, and n is the number
of doubles to extract. n is actually the size of the first dimension
of the extracted array and could be followed by other dimensions to
extract multidimensional arrays.

An example:
a=dblarr(5)+!dpi ; Create a 5 element double array.
b=byte(a,0,8,5) ; Convert it to an 8 x 5 byte array.
print,b ; Look at it.
64 9 33 251 84 68 45 24
64 9 33 251 84 68 45 24
64 9 33 251 84 68 45 24
64 9 33 251 84 68 45 24
64 9 33 251 84 68 45 24
print,double(b,0,5) ; Extract & print the original values.

Ray Sterner sterner@tesla.jhuapl.edu
Johns Hopkins University North latitude 39.16 degrees.
Applied Physics Laboratory West longitude 76.90 degrees.
Laurel, MD 20723-6099
[Message index]
 
Read Message
Read Message
Previous Topic: Frustrated with SURFACE,/HORIZONTAL
Next Topic: Re: Any fix for IDL + MacX?

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

Current Time: Sat Oct 11 19:05:34 PDT 2025

Total time taken to generate the page: 1.92496 seconds