IteratorRandom::choose() uses a floating-point reciprocal to calculate probabilities. f64 reciprocal is an inexact operation with residuals on the order of 1 / 2^54.
For example: the probability of gen_bool(1.0 / 3) == true is: 6004799503160661/18014398509481984, which differs from 1/3 in the 17th digit.
An exact implementation of choose would be possible with gen_range.
IteratorRandom::choose()uses a floating-point reciprocal to calculate probabilities. f64 reciprocal is an inexact operation with residuals on the order of 1 / 2^54.For example: the probability of
gen_bool(1.0 / 3) == trueis: 6004799503160661/18014398509481984, which differs from 1/3 in the 17th digit.An exact implementation of
choosewould be possible withgen_range.