Re: convert decimal -> hexadecimal [message #52025] |
Thu, 21 December 2006 09:44 |
Laurens
Messages: 41 Registered: May 2006
|
Member |
|
|
Michael Galloy wrote:
> Laurens wrote:
>> I have a decimal variable (aka nr = 84), which needs to be converted
>> to a hexadecimal representation of it (aka nr_hex = 54).
>> I found a solution with reads to convert from hexadecimal to decimal
>> but I need it the other way around...
>>
>> Any ideas?
>
> How about the Z format:
>
> IDL> nr = 84
> IDL> print, nr, format='(Z)'
> 54
> IDL> nr_hex = string(nr, format='(Z)')
> IDL> help, nr_hex
> NR_HEX STRING = ' 54'
>
> Mike
> --
> www.michaelgalloy.com
I knew it was that simple :) Was trying things with reads and printf,
but this does the job :)
Thnx!
Laurens
|
|
|
Re: convert decimal -> hexadecimal [message #52027 is a reply to message #52025] |
Thu, 21 December 2006 09:23  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Laurens wrote:
> I have a decimal variable (aka nr = 84), which needs to be converted to
> a hexadecimal representation of it (aka nr_hex = 54).
> I found a solution with reads to convert from hexadecimal to decimal but
> I need it the other way around...
>
> Any ideas?
How about the Z format:
IDL> nr = 84
IDL> print, nr, format='(Z)'
54
IDL> nr_hex = string(nr, format='(Z)')
IDL> help, nr_hex
NR_HEX STRING = ' 54'
Mike
--
www.michaelgalloy.com
|
|
|