Repository navigation
Fixed
ConsistentRandom#randcan no longer return an out of range value. Previously there was a very small chance (about 1 in 2⁵³) that a seed could produce a value of exactly 1.0, causingrandto return 1.0,rand(n)to returnn, andrand(range)to return a value above the range. Random floats are now derived from the top 53 bits of the seed, guaranteeing a uniform value in[0, 1). Note: this changes the exact values generated for existing seeds (the distribution is unchanged), so percentage rollouts in flight during an upgrade may reassign.- Fixed distribution bias in
ConsistentRandom#randfor ranges with negative bounds. Values were truncated toward zero instead of floored, so for a range like-5..5the minimum value was never returned and zero was returned twice as often as other values. ConsistentRandom#randnow raises anArgumentErrorfor empty ranges (e.g.5..1) and non-numeric ranges instead of returning out of range values or raising aNoMethodError.ConsistentRandom::Testing#bytesnow raises anArgumentErrorfor empty strings, which were previously accepted but silently ignored, producing non-deterministic values in tests.
Changed
ConsistentRandom.current_seedis now public API; it can be used to propagate a scope into threads or fibers, which do not inherit the fiber-local scope state.
Full Changelog: v2.2.0...v2.3.0