Tuesday, March 30, 2010


Oops! Code while distracted on weekends, repent while distracted next weekday. I found a bug in the nextNibble function of the BC32 library. The fix shown below and has also been applied to the original blog post. It doesn’t affect any of the existing examples, but might have shown up in other BC32 programs.

Since my policy is never to fix one bug without introducing the possibility of others (lol), I also made some improvements to the code.

My apologies, Neil.

(As always, presented “as-is” and without warranty or implied fitness; use at your own risk.)
// Aligns a power of two to the next block.
let rec internal nextBlock (n:int)
(f:int) =
match (n<=b) with
| true -> b
| _ -> nextBlock n (b*f) f

// Align to the next nibble.
let rec internal nextNibble (n:int) =
nextBlock n 16 16

No comments: