[Bug libstdc++/89979] subtract_with_carry_engine incorrect carry flag

gcc@christoph-conrads.name gcc-bugzilla@gcc.gnu.org
Tue Aug 31 09:39:24 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89979

--- Comment #4 from Christoph Conrads <gcc@christoph-conrads.name> ---
> LLVM's libc++ does not go into the 0 loop but still does not do a good job:

The subtract-with-carry PRNG is a simple PRNG, it has a very long period whose
length can be proved with elementary number theory but the randomness
properties of an SWC on its own are bad which is why you have to discard a lot
of values. For reference, std::ranlux48 uses about 11 out of 389 values and you
can detect (self-advertisement: it discards much less variates if you you use
my parameters: b=32, s=2, r=13, see
https://github.com/boostorg/random/issues/57).

Here are the random values are drawing 100 times:

114294 141465 4294632814 252684 106646 4294497449 475286

Here are the random values after drawing 1000 times:

3844519667 4029384828 773557245 3005408692 1891078342 2314767096 2602358454

After drawing 2000 times:

671901017 3735908022 2276383719 2942324048 2197640583 3544339665 2823890385


More information about the Gcc-bugs mailing list