Not a bug. But really confusing when you're looking for binary manipulation
functions!

enbase takes your string and returns another string. The returned string is
an encoding of your value in your choosen representation. Here you elected
to use a base 2 encoding. Therefore enbase returned you a string of "1"s and
"0"s.
What was the value you encoded? Ascii.

>> enbase/base "2" 2    ; Encode string into a binary encoding using base 2.
== "00110010"

A related function is debase. Debase will convert a string into binary. It
does this by decoding the representation stored in the string.

debase/base "00110010" 2    ; Interpret string as base 2 encoded binary.
== #{32}

>> to-integer #{32}     ; Interpret hex as integer.
== 50

>> to-char 50      ; Interpret integer as character (or you can think of it
as a byte of that value)
== #"2"

You could also do

>> to-string #{32} ; Interpret binary as string.
== "2"

So here's how to get the result you first expected

>> enbase/base to-string to-char 2 2
== "00000010"

And to do a complete the loop.

>> to-string debase/base enbase/base "The quick brown fox." 2 2
== "The quick brown fox."

Hope it helps.
Brett Handley.

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 21, 2000 10:18 AM
Subject: [REBOL] ENBASE bug


> Does anyone know if enbase/base refinement has a bug.  When I do the
> following:
>
> a: "2"
> enbase/base a 2
>
> I get:
>
> >>"00110010"
>
> This must be a bug or I need more understanding.
>
>
> --
> Is your email secure? http://www.pop3now.com
> (c) 1998-2000 secureFront Technologies, Inc. All rights reserved.
>

Reply via email to