<putting on my “I dealt with real cryptography (not weird ‘currency’ nonsense), and had to deal with non-expert code” hat :D >

In fairness this approach is also biased in an attackable way :D

Of course, now I’m curious about what happens in the floating point [0..1) case in [std]libc++...

<end hat>

I stil feel that the random interfaces in the standard library are bad: they make it hard to do the most simple cases, and they make it easy to make errors in complex/sensitive cases.

—Oliver

On Aug 30, 2025, at 1:45 PM, zxuiji via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

Uh, why is this difficult? It's literally just this:

int rand_of_range( int *seed, int min, int max )
      { int cap = max - min; return cap ? (rand_r(seed) % cap) + min : min; }

On Sat, 30 Aug 2025 at 21:19, Paul Caprioli via Std-Proposals <std-proposals@lists.isocpp.org> wrote:

> Can you guys please add a feature, where you can limit the random, without math?
> I ask because memorizing  int random_num = min_val + rand() % (max_val - min_val + 1); isnt easy

Is std::uniform_int_distribution suitable for your use?
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals