top | item 39745561

(no title)

eutectic | 1 year ago

Here's a variant which gives 64-bit output:

  uint64_t x = 0, w = 1;
  uint64_t msws64(void) {
      x = x * x + (w *= 0xe9acc0f334e93bd5ULL);
      return (x = (x >> 32) | (x << 32)) ^ w;
  }

discuss

order

camel-cdr|1 year ago

I wouldn't recemmend that without a 128 bit variables. The truncation is required to make the generator non predictable, otherwise you leak to much state.

Alternatively, you can just call the 32 bit one twice and build a 64 bit value from the results.

Edit: I didn't see that you changed the algorithm more than removing the truncation. It is honestly suprizingly good for exposing that much state, but it fails PractRand after 16 GB.

It is honestly suprizingly good and hasn't failed PractRand yet (I'm at >64 GB).

eutectic|1 year ago

Your edit is confusing me. Which variant fails and which variant passes?