Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Converting a hex string into an integer

 [1/3] from: gavin:mckenzie:sympatico:ca at: 12-Jul-2001 15:26


*sigh* Just when you think you've got the knack of this language, something seemingly simple stumps ya'. Given:
>> a: "#x3c"
== "#x3c" I now want to convert the "3c" (hex) portion of the string into its decimal value. I've read up on to-integer, debase, and countless other parts of the dictionary and user guide. I'm sure there is a really simple way to do this, but so far all I've come up with is:
>> to-integer do do [rejoin ["#{" next next a "}"]]
== 60 I look forward to being wholly and completely shamed...please. Gavin.

 [2/3] from: larry::ecotope::com at: 12-Jul-2001 13:16


Hi Gavin
>> a: "#x3c"
== "#x3c"
>> to-integer to-issue skip a 2
== 60
>>
Maybe others can find an even shorter conversion? -Larry

 [3/3] from: gavin:mckenzie:sympatico:ca at: 12-Jul-2001 17:06


(ahem)...suitably shamed. "to-issue" eh? That's the ticket. Thank you. Gavin.