[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hexadecimal variables



Hi,

Pavel Romashkin wrote:
> 
> Hi,
> Is there a nice way to convert hexadecimal variables? Here's what I am
> trying to do:
> 
> This is received from the outside.
>     h_string = '40000FC0DA'
>
> [...] Can anyone suggest a neater way
> to do this?  Maybe, there is a way to use Z-formatted READ here?

You've got it, using ReadS (read from string). It looks like you have five
bytes so you need a very long integer to store this, giving me the first
chance I've had to use IDL 5.2's new data types:

IDL> h_string = '40000FC0DA'
IDL> long64=0LL
IDL> ReadS, h_string, long64, Format='(Z0)'
IDL> help, long64
LONG64          LONG64    =           274878939354

Hope this works OK for you.

Cheers,
-- 
-Dick

Dick Jackson             Fanning Software Consulting, Canadian Office
djackson@dfanning.com    Calgary, Alberta   Voice/Fax: (403) 242-7398
    Coyote's Guide to IDL Programming: http://www.dfanning.com/