Converting Hexadecimal Strings to Numbers
QUESTION: I have a hexadecimal value, 38fb, that I have read out of a file as a string. How can I convert this value to a long integer? If I try to use LONG I get a string conversion error.
ANSWER: You want to use the IDL function READS to read the string with a hexadecimal format and do the conversion for you. Your code will look like this:
IDL> theString = '38fb' IDL> theNumber = 0L IDL> ReadS, theString, theNumber, Format='(Z)' IDL> Print, theNumber 14587
Copyright © 2005 David W. Fanning
Last Updated 4 June 2005