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

Home » Public Forums » archive » Re: convert decimal -> hexadecimal
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
Re: convert decimal -> hexadecimal [message #52025] Thu, 21 December 2006 09:44
Laurens is currently offline  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 Go to previous message
Michael Galloy is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to IDL to XML using XMLffDOMDocument
Next Topic: Image segmentation programs in IDL?

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

Current Time: Fri Oct 10 07:59:18 PDT 2025

Total time taken to generate the page: 1.27986 seconds