Hi Alan,

On Monday, September 9, 2002, 5:24:57 PM, you wrote:

ap> Is there an easy way to represent numbers in their binary form?

This is the easy way, provided you're on a little-endian platform:

>> s: make struct! [num [integer!]] [0]
>> integer-to-binary: func [i [integer!]] [s/num: i head reverse third s]
>> integer-to-binary 100
== #{00000064}
>> integer-to-binary 100000000
== #{05F5E100}

On big-endian platforms you just don't need to REVERSE it.

A (probably slower, but didn't test it) multiplatform way is:

>> integer-to-binary: func [i [integer!]] [debase/base to-hex i 16]
>> integer-to-binary 100000000
== #{05F5E100}

Regards,
   Gabriele.
-- 
Gabriele Santilli <[EMAIL PROTECTED]>  --  REBOL Programmer
Amigan -- AGI L'Aquila -- REB: http://web.tiscali.it/rebol/index.r

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to