f

#### Convert 8 byte array to double

```I'm working with DICOM files where a floating number is saved as BYTE array=
[8] and I know (at least pretty sure) it is a double precision floating num=
ber, but I cannot figure out how to convert it to DOUBLE.

IDL> help, a
A    BYTE      =3D Array[8]
IDL> print, a
51  51  51  51  51  51 227  63
IDL> print, string(a)
333333=C3=A3?
IDL> print, string(a, format=3D'(Z)')
33      33      33      33      33      33      E3      3F
IDL> print, double(a)
51.000000       51.000000       51.000000       51.000000       51.0=
00000       51.000000       227.00000       63.000000

I understand that I can calculate it myself, but that will require a whole =
lot of code and quite some reading to understand howto. Anybody know of an =
easier way? As DOUBLE really is a 64bit number...

I have also a feeling that this is swapped endian, or what it is called. (3=
F first, 33 last).

```
 0
LNpellen
12/21/2016 10:25:06 AM
comp.lang.idl-pvwave 12260 articles. 4 followers.

2 Replies
709 Views

Similar Articles

[PageSpeed] 35

```Try:

a=[51b,51b,51b,51b,51b,51b,227b,63b]
print,float(a,0,1)

or if swapped:

print,float(reverse(a),0,1)

HTH, Heinz
```
 0
Heinz
12/21/2016 10:47:32 AM
```One more thought: Of course you have to use double instead of float.
If you are expecting 0.6 as the result, the given number is little
endian. This can be considered in by:

litle_endian=byte(1s,0,1)
print,double(litle_endian? a : reverse(a),0,1)

Cheers, Heinz
```
 0
Heinz
12/21/2016 11:19:06 AM