Hi,

While working with hexadecimal values I found two aproaches - first one
- using issues, and second one - using binary values:

->> to-integer #{FF}
== 255
->> to-integer #FF
== 255
->> to-integer #00FF
== 255
->> to-integer #{00FF}
== 255

->> help enbase
USAGE:
    ENBASE value /base base-value

DESCRIPTION:
     Converts a string to a different base representation.
     ENBASE is a native value.

ARGUMENTS:
     value -- The string to encode (Type: any-string)

REFINEMENTS:
     /base -- Allow a selection of a different base for conversion
         base-value -- The base to convert to: 64, 16, or 2 (Type: any)

->> enbase/base #FF 2
== "0100011001000110"

What's that? Bug or what? I would assume obtaining "11111111", as in
following example:

->> enbase/base #{FF}2
== "11111111"

->> x: (to-integer #{A1}) + (to-integer #{10})
== 177
->> to-hex x
== #000000B1
->> enbase/base to-hex x 2
== {0011000000110000001100000011000000110000001100000100001000110001}
->> enbase/base #{000000B1} 2
==  "00000000000000000000000010110001"

Which in turn really represents 177:

>> to-integer debase/base "00000000000000000000000010110001" 2
== 177

Even 'debase returned binary datatype, so why to-hex returns an issue?

Thanks,

-pekr-

Reply via email to