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

Handling hexes

 [1/3] from: chalz::earthlink::net at: 2-Nov-2002 12:10


Greets folks. A bit of a question. I'm working with ascii<->hex here, and am only finding to-hex and dehex in REBOL, and to-hex only works on int, and returns a series! which looks like #00000043. I want to convert that to a normal 256 style of 2 values each (43). Sure, I can parse or replace the 0's, but when I get to say #00000050 then I have a problem. Unless I do replace/all value "00" "", which fubars at #00000100 (which is 256 - I know, in base-256 you go 0 to 255, which is FF). Does anyone have a far better method? It's rather annoying trying to convert val: to-hex 24 and convert val back to 24 (for checking). Thanks all.

 [2/3] from: tomc:darkwing:uoregon at: 2-Nov-2002 11:47


I have used this -- not that it is pretty hex: join "%" [back back tail(to-string(to-hex(to-integer chr)))] On Sat, 2 Nov 2002, Charles wrote:

 [3/3] from: carl:cybercraft at: 3-Nov-2002 9:08


On 03-Nov-02, Charles wrote:
> Greets folks. A bit of a question. I'm working with ascii<->hex > here, and am only finding to-hex and dehex in REBOL, and to-hex only
<<quoted lines omitted: 6>>
> It's rather annoying trying to convert val: to-hex 24 and convert > val back to 24 (for checking). Thanks all.
Do (the last lines) of these do what you want? ...
>> to-hex 24
== #00000018
>> skip to-hex 24 6
== #18
>> to-string skip to-hex 24 6
== "18"
>> to-integer #18
== 24
>> type? #18
== issue!
>> to-issue "18"
== #18
>> to-integer to-issue "18"
== 24 Not sure how you'd handle decimal values though. It'd depend on what you're wanting to do with them. -- Carl Read

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted