TOHEX considerations for 64 bit integers
When using tohex in REBOL 3.0 be aware that the returned
hexidecimal string will be longer due to the use of 64 bit integers.
For example, in REBOL 2.6, 32 bit integers resulted in:
>> tohex 1
== #00000001
In REBOL 3.0, the results will be appropriate to 64 bit integers:
>> tohex 1
== #0000000000000001
To help deal with this, a /size refinement has been added. It
specifies the number of hex digits to return. For example, to
request the same result as in REBOL 2.5, you can write:
>> tohex/size 1 8
== #00000001
tohex/size 1 8
== #FFFFFFFF
Of course, for numbers larger than 32 bits, this is problematic because the
result will be clipped at eight digits.
Also, for convenience, the tohex function has been expanded to allow
character and tuple values. For example:
>> tohex first "REBOL"
== #52
>> tohex first ##{005200450042004f004c} ; unicode
== #0052
The tuple datatype conversion to hex is handy for converting REBOL
colors to HTML color values:
>> tohex 255.150.50
== #FF9632
(But be careful if the value contains an alpha value.)
18 Comments
