For example, this program will not terminate:
import "lib/github.com/diku-dk/cpprandom/random"
module rng = minstd_rand
module dist = uniform_int_distribution u32 rng
let main (seed: i32) =
let r = rng.rng_from_seed [seed]
in dist.rand (rng.min,rng.max+1) r
The problem is this loop where it tries to ensure that the distribution is not unbalanced. If the range is too great, then secure_max becomes 0, and the loop becomes infinite.
For example, this program will not terminate:
The problem is this loop where it tries to ensure that the distribution is not unbalanced. If the range is too great, then
secure_maxbecomes 0, and the loop becomes infinite.