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

to-hex

 [1/5] from: hallvard::ystad::helpinhand::com at: 11-Sep-2001 16:19


pekr wrote (Tuesday 11.09.2001, at 11.24):
>load rejoin ["#{" "F2" "}"] - that cludgy way you get binary :-) then you >can convert to integer >[...] >maybe 'debase could help you, but it is buggy in current rebol >implementation ...
I've been looking at debase too, but as you say, it's buggy. If I were to convert hex characters manually in java (that's where I "come from"), I'd use a switch statement. Any suggestions to how I should do it in rebol? Here's a java sample: switch (character) { case ('0') return "0000" case ('1') return "0001" case ('2') return "0010" (...) case ('d') return "1101" case ('e') return "1110" case ('f') return "1111" } Obviously, this should be done with a one-liner, but since debase is so hard to figure out, I'm willing to do a little more work. Any help greatly appreciated. ~H

 [2/5] from: dockimbel:free at: 11-Sep-2001 17:14


Hi, Hallvard Ystad wrote:
> And from the hex value F2, (or the integer value 242), how do I get the string "11110010"? >
Try :
>> enbase/base #{F2} 2
== "11110010" HTH, DocKimbel.

 [3/5] from: hallvard:ystad:helpinhand at: 11-Sep-2001 11:07


Hi everyone. Here's a simple question: To-hex demands an integer value. How do I convert the string "F2" into a hex value? To-integer claims "F2" is an invalid argument. ~H

 [4/5] from: petr:krenzelok:trz:cz at: 11-Sep-2001 11:24


Hallvard Ystad wrote:
> Hi everyone. Here's a simple question: > > To-hex demands an integer value. How do I convert the string "F2" into a hex value? To-integer claims "F2" is an invalid argument. >
load rejoin ["#{" "F2" "}"] - that cludgy way you get binary :-) then you can convert to integer to-integer load rejoin ["#{" "F2" "}"] - and now you can convert to-hex :-) to-hex to-integer load rejoin ["#{" "F2" "}"] maybe 'debase could help you, but it is buggy in current rebol implementation ... -pekr-

 [5/5] from: hallvard:ystad:helpinhand at: 11-Sep-2001 12:01


And from the hex value F2, (or the integer value 242), how do I get the string "11110010"? ~H Du skrev (11.24 11.09.2001):