From: "mweitekamp (Monica Weitekamp)" Date: 2022-11-02T16:10:41+00:00 Subject: [ruby-core:110584] [Ruby master Bug#19100] Ruby 3 PRNG values diverge from Ruby 2 for some initial values Issue #19100 has been reported by mweitekamp (Monica Weitekamp). ---------------------------------------- Bug #19100: Ruby 3 PRNG values diverge from Ruby 2 for some initial values https://bugs.ruby-lang.org/issues/19100 * Author: mweitekamp (Monica Weitekamp) * Status: Open * Priority: Normal * ruby -v: 3.1.2 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- The outputs of the Mersenne Twister implementation diverged from their expected results in Ruby 2 for initial pseudo-random number generator seeds between 2^32 and 2^33-1, inclusive. I used ruby versions 2.7.4 vs. 3.0.3, 3.0.4, and 3.1.2 to compare. ``` ruby ARBITRARY_RAND_MAX = 2**32 # The below three outputs should generate different outputs in ruby 2 and ruby 3 prng = Random.new(2**32) puts prng.seed puts prng.rand(ARBITRARY_RAND_MAX) prng2 = Random.new(2**33-1) puts prng2.seed puts prng2.rand(ARBITRARY_RAND_MAX) prng3 = Random.new((2**32 + 2**33-1) / 2) puts prng3.seed puts prng3.rand(ARBITRARY_RAND_MAX) # These next two examples should generate the same outputs in ruby 2 and ruby 3 prng4 = Random.new(2**32 - 1) puts prng4.seed puts prng4.rand(ARBITRARY_RAND_MAX) prng5 = Random.new(2**33) puts prng5.seed puts prng5.rand(ARBITRARY_RAND_MAX) ``` -- https://bugs.ruby-lang.org/ Unsubscribe: