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

Home » Public Forums » archive » 8 byte to double?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
8 byte to double? [message #92599] Wed, 20 January 2016 04:39 Go to next message
LNpellen is currently offline  LNpellen
Messages: 37
Registered: November 2009
Member
I'm lost - and I thought I had solved this previously, but I simply can't find it (maybe it was in php or something...).

Some values in the DICOM header for some vendors happens to save floating (double-presition?) values as 8-bytearrays

Is there a simple way in IDL to convert this bytearray to a double without coding the type conversion yourself?

I couldn't manage to use the DOUBLE function for this.

Ex.:
I have the byte array [205 204 204 204 204 204 49 64] and it think from my annoyingly short notes that it should be 17.8...?

Best regards,
Ellen
Re: 8 byte to double? [message #92600 is a reply to message #92599] Wed, 20 January 2016 04:58 Go to previous messageGo to next message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Wednesday, January 20, 2016 at 1:39:07 PM UTC+1, LNpellen wrote:
> I'm lost - and I thought I had solved this previously, but I simply can't find it (maybe it was in php or something...).
>
> Some values in the DICOM header for some vendors happens to save floating (double-presition?) values as 8-bytearrays
>
> Is there a simple way in IDL to convert this bytearray to a double without coding the type conversion yourself?
>
> I couldn't manage to use the DOUBLE function for this.
>
> Ex.:
> I have the byte array [205 204 204 204 204 204 49 64] and it think from my annoyingly short notes that it should be 17.8...?
>
> Best regards,
> Ellen

IDL> b=[205b,204b,204b,204b,204b,204b,49b,64b]
IDL> print, fix(b, 0, 1, type=5)
17.800000

regards,
Lajos
Re: 8 byte to double? [message #92601 is a reply to message #92600] Wed, 20 January 2016 05:34 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
fawltylanguage@gmail.com writes:

>
> On Wednesday, January 20, 2016 at 1:39:07 PM UTC+1, LNpellen wrote:
>> I'm lost - and I thought I had solved this previously, but I simply can't find it (maybe it was in php or something...).
>>
>> Some values in the DICOM header for some vendors happens to save floating (double-presition?) values as 8-bytearrays
>>
>> Is there a simple way in IDL to convert this bytearray to a double without coding the type conversion yourself?
>>
>> I couldn't manage to use the DOUBLE function for this.
>>
>> Ex.:
>> I have the byte array [205 204 204 204 204 204 49 64] and it think from my annoyingly short notes that it should be 17.8...?
>>
>> Best regards,
>> Ellen
>
> IDL> b=[205b,204b,204b,204b,204b,204b,49b,64b]
> IDL> print, fix(b, 0, 1, type=5)
> 17.800000

Lajos is right, but here is a little fuller explanation:


http://www.idlcoyote.com/code_tips/packfloat.php

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: 8 byte to double? [message #92602 is a reply to message #92599] Wed, 20 January 2016 05:45 Go to previous message
LNpellen is currently offline  LNpellen
Messages: 37
Registered: November 2009
Member
I love you both :)

Lajos for getting me straight to the solution and David for giving me the chance to learn what I'm doing.

Cheers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: MODIS Conversion ToolKit is not working? Can anyone help me?
Next Topic: HDF_SD_START: Invalid HDF file or filename: problem related to network issues

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

Current Time: Wed Oct 08 07:14:53 PDT 2025

Total time taken to generate the page: 0.00438 seconds