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

[REBOL] Re: subtracting binaries

From: greggirwin:mindspring at: 5-Apr-2004 16:59

Oops! Small glitch in the optimized version (missed a bit). Fixed: add-bitsets: func [a b /local c i n carry] [ carry: 0 c: make bitset! length? a repeat i (length? a) [ n: i - 1 switch carry + add get-bit a n get-bit b n [ 0 [] 1 [set-bit c n carry: 0] 2 [carry: 1] 3 [set-bit c n carry: 1] ] ] if carry <> 0 [ i: 0 while [bit-set? c i][ clear-bit c i i: i + 1 ] set-bit c i ] c ] -- Gregg