Skip to content

v2.3.0

Latest

Choose a tag to compare

@bdurand bdurand released this 11 Jul 16:57
· 6 commits to main since this release
Immutable release. Only release title and notes can be modified.
3808e68

Fixed

  • ConsistentRandom#rand can 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, causing rand to return 1.0, rand(n) to return n, and rand(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#rand for ranges with negative bounds. Values were truncated toward zero instead of floored, so for a range like -5..5 the minimum value was never returned and zero was returned twice as often as other values.
  • ConsistentRandom#rand now raises an ArgumentError for empty ranges (e.g. 5..1) and non-numeric ranges instead of returning out of range values or raising a NoMethodError.
  • ConsistentRandom::Testing#bytes now raises an ArgumentError for empty strings, which were previously accepted but silently ignored, producing non-deterministic values in tests.

Changed

  • ConsistentRandom.current_seed is 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