[REBOL] Re: bit shifts
From: ryanc:iesco-dms at: 20-Sep-2001 10:19
Hallvard Ystad wrote:
> ">> stats rebol
> You are not a member of list 'rebol' "
>
> ... strange, since I didn't unsubscribe... Anyway, I posted something
> earlier today, here goes again:
>
> Gregg Irwin skrev (Tuesday 11.09.2001, kl. 23.31):
> >If you're working with numeric values you can multiply or divide, by
> >powers
> >of two.
> >For example (please correct any misinformation REBOLers!):
> >
> > shl: to-integer (value * (2 ** shift-count))
> > shr: to-integer (value / (2 ** shift-count))
>
> Well, this mostly works, but wheras the integer value 1 right-shifted
> becomes 0, the same value divided by 2 becomes 0,5. Even if one should
> round the value (how do we do so in rebol, by the way?), it would become 1,
> not 0. So I think it's better to shift "à proprement dire".
Rebol has no rounding function. Here is routine that I have used forever, and
it makes a nice rebol one liner.
round-off: func [v [number!]][to-integer v + either v > 0 [.5][-.5]]
>
> Your other routines seem to work, but only partially, I'm afraid. It seems
> rebol has great problems with the debase function... But thanks anyway.
Wow! Your not kidding! It crashes on me bigtime. Has anybody done a feedback?
> ~H
>
> Praetera censeo Carthaginem esse delendam
>
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400