drand48 0.2.0-beta.2

drand48 - POSIX.1 standard LCG random number generator
Documentation

drand48 POSIX.1 random number generator

drand48 is the random mumber generator included in POSIX / ANSI-C standard employed by drand48() function family.

It is LCG with mod = 2^48, a = 25214903917, c = 11

Functions

POSIX compatible '48 functions:

  1. drand
  2. frand (not exists in POSIX standard)
  3. mrand
  4. lrand
  5. srand

Byte extracting functions

  1. get_bytes
  2. get_bytes3
  3. fill_bytes

16-bit conversion

We take the best top bits, discarding lower ones.

  1. get_i16
  2. get_u16

Seed functions

  1. verify_seed
  2. clamp_seed

Spectral test

2d 3d 4d 5d 6d 7d 8d
0.51 0.80 0.45 0.58 0.66 0.80 0.60

Compatibility

This version of drand48 matches outputs of drand() family in FreeBSD 13 libc.

No copyright

This is free and unencumbered software released into the public domain.

You may use, modify, distribute, and contribute to this code without restriction. To the extent possible under law, the author(s) of this work waive all copyright and related rights.

Licensed under CC0-1.0 OR Unlicense.

Unlicense logo