Related to #875
During the tests, we discovered inconsistency in endianness when comparing the outputs from rand 0.4.0 and rand 0.7.0.
As an extension to #875, tests are run to check if next_u64 is consistent across versions. These tests shows that the byte order of the output has switched.
For instance, on rand 0.4.0, running the following code
let mut rng = rand::ChaChaRng::new_unseeded();
let lower = 88293;
let higher = 9300932;
rng.set_counter(lower, higher);
assert_eq_bin!(4060232610, rng.next_u32());
assert_eq_bin!(2786236710, rng.next_u32());
assert_eq_bin!(3748877652, rng.next_u32());
assert_eq_bin!(3324792667, rng.next_u32());
println!("{:b}", rng.next_u64());
gives
10100111101100110100101110001011
00000000011011000000000000111011
With rand 0.7.0, running the following
let mut rng = ChaChaRng::from_seed([0u8; 32]);
let lower = 88293;
let higher = 9300932;
rng.set_word_pos(lower << 4);
rng.set_stream(higher);
assert_eq!(4060232610, rng.next_u32());
assert_eq!(2786236710, rng.next_u32());
assert_eq!(3748877652, rng.next_u32());
assert_eq!(3324792667, rng.next_u32());
println!("{:b}", rng.next_u64());
gives us
00000000011011000000000000111011
10100111101100110100101110001011
So byte orders are reversed.
I also reviewed the wordings of RngCore trait, and the required methods have no guarantees on the byte order of next_* methods.
Maybe we should enforce some form of endianness requirement?
Related to #875
During the tests, we discovered inconsistency in endianness when comparing the outputs from
rand0.4.0 andrand0.7.0.As an extension to #875, tests are run to check if
next_u64is consistent across versions. These tests shows that the byte order of the output has switched.For instance, on
rand0.4.0, running the following codegives
With
rand0.7.0, running the followinggives us
So byte orders are reversed.
I also reviewed the wordings of
RngCoretrait, and the required methods have no guarantees on the byte order ofnext_*methods.Maybe we should enforce some form of endianness requirement?