Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: bit shifts

From: hallvard:ystad:helpinhand at: 20-Sep-2001 13:16

>> 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". 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. ~H