Changelog
View Source0.1.1
Changed
knot:uniform/1spec tightened frompos_integer() -> pos_integer()to1..4294967295 -> 1..4294967295. The NIF's C-side argument isenif_get_uint(unsigned 32-bit), so values above2^32 - 1raisebadarg. The previous spec lied — dialyzer now catches the out-of-range cases at compile time.Module and function docstrings (
@doc) added — algorithm, per-thread state, lazy seeding, the bounded-output bias bound, and thebadargsemantics for over-range inputs are now in the generated hexdocs without having to readc_src/knot.c.
No behavioural changes; no new code paths.
0.1.0
Initial release.
knot:uniform/1— fast non-cryptographic PRNG NIF, drop-in replacement forgranderl:uniform/1. Uses wyrand (1 multiply + 1 xor + 1 add per draw, BigCrush-passing) with the biased multiply-and-shift bounded method (single multiply, no rejection branch; bias < 1e-7 for bounds ≤ 256).- Pure C NIF — ~75 LOC. No Rust toolchain, no cargo, no rustler.
Per-OS-thread state via
__thread. Lazy seed fromgetrandom/arc4random_buf. - Build via
c_src/build.sh(granderl-stylepre_hooks), with the OTP 27+erl -noshell -s init stop -evalorder bug fixed —-evalruns before init terminates.