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:
- drand
- frand (not exists in POSIX standard)
- mrand
- lrand
- srand
Byte extracting functions
- get_bytes
- get_bytes3
- fill_bytes
16-bit conversion
We take the best top bits, discarding lower ones.
- get_i16
- get_u16
Seed functions
- verify_seed
- 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.
![]()