C++ Logo

std-proposals

Advanced search

Re: [std-proposals] solution proposal for Issue 2524: generate_canonical can occasionally return 1.0

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 5 Dec 2025 19:45:49 +0000
On Fri, 5 Dec 2025 at 18:54, Paul Caprioli <paul_at_[hidden]> wrote:

> > When the full range of the URBG is (2^N - 1) for any N, there is never a
> need to discard any values from the URBG. So if you are only concerned with
> the additional discards being done, just make sure your URBG is sensible.
> If your URBG returns any value in the range [0,UINT_MAX) or [0,ULLONG_MAX)
> then there will be no discarded values.
>
> Minor typo above: I think the guarantee is for a URBG providing the closed
> range [0,UINT_MAX] or [0,ULLONG_MAX].
>

Oops, yes, that's right. I was thinking of [0, 2^N).

Basically, if it is a uniform random *bit* generator (like the name
suggests) and so every bit has an equal chance of being set or not, then
there's no need to discard any values.

Received on 2025-12-05 19:46:10