From: "shyouhei (Shyouhei Urabe)" Date: 2022-11-07T07:41:20+00:00 Subject: [ruby-core:110634] [Ruby master Bug#19100] Ruby 3 PRNG values diverge from Ruby 2 for some initial values Issue #19100 has been updated by shyouhei (Shyouhei Urabe). Status changed from Open to Assigned Assignee set to nobu (Nobuyoshi Nakada) Can confirm, and my `git bisect` shows that this was introduced in commit:af5e87ab218c5f4e34c6cdb54ae119a7f0f9033f. @nobu can you take a look? ---------------------------------------- Bug #19100: Ruby 3 PRNG values diverge from Ruby 2 for some initial values https://bugs.ruby-lang.org/issues/19100#change-99972 * Author: mweitekamp (Monica Weitekamp) * Status: Assigned * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * 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: