[REBOL] Re: Bitwise operations
From: krobillard:cox at: 14-Aug-2003 22:19
On Thursday 14 August 2003 06:36 pm, you wrote:
> Until RT releases the plugin API so you'll be able to code them in C
> directly, here's a faster implementation of these functions :
> bin16: func [n][at debase/base to-hex n 16 3]
> bin16-le: func [n][copy/part head reverse debase/base to-hex n 16 2]
> bin32: func [n][debase/base to-hex n 16]
> bin32-le: func [n][head reverse debase/base to-hex n 16]
> swap16: swap32: func [data][to integer! head reverse data]
Thanks for improvments Nenad. Swap16/32 need a copy/part 2 or copy/part 4 for
the way I use them, but this is much better. Your bin16 is twice as fast and
bin32 is six times faster.
I seem to recall playing with debase but I can't remember why I didn't use it.