Skip to content

fix: remove modulo bias from random helper#93

Open
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-random-uniform-distribution
Open

fix: remove modulo bias from random helper#93
Ap4sh wants to merge 1 commit into
session-foundation:devfrom
Ap4sh:fix-random-uniform-distribution

Conversation

@Ap4sh

@Ap4sh Ap4sh commented Jun 21, 2026

Copy link
Copy Markdown

This replaces the % range reduction in random::get_uniform_distribution with std::uniform_int_distribution, using the existing libsodium-backed CSRNG

That keeps the helper aligned with its documented uniform behavior, while preserving the existing min > max fallback. The new tests cover equal bounds, inverted bounds, signed ranges, unsigned ranges, and full-width 64-bit ranges

testing

  • ./utils/format.sh verify
  • git diff --check
  • cmake --build Build-pr-system --parallel --verbose
  • ./Build-pr-system/tests/testLogging --colour-mode none -d yes
  • ./Build-pr-system/tests/testAll "[random]" --colour-mode none -d yes
  • ./Build-pr-system/tests/testAll --colour-mode none -d yes

@Ap4sh Ap4sh marked this pull request as ready for review June 21, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant