19 Feb 2010 ingvar   » (Master)

This morning, I finished off and packaged up a library (CL, linux; other OSes with CL implementations and OS-provided random (or random-backed pseudorandom) devices can probably be grafted in, but would require volunteers to test) to extract random bits from /dev/urandom and use those essentially unadorned to generate random numbers.

There's a single exported function from the package, RANDOMNESS:RND and takes an integer argument (I guess you could try feeding it a float, but it wouldn't do you that much good). That function then proceeds to extract log2 N bits and uses rejection smapling to find an integer in the 0..(N-1) span. As the bits sucked out of the internal pool run out (each bit is used only the once), they're replenished from the OS-provided randomness source.

All very nice, with some interesting corner cases for the unwary and probably still bug-ridden. But, such is life.

Download from here.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!