Skip to content

Commit 1ca4d7c

Browse files
authored
[stdlib] Make unavailable protocol implementation @_alwaysEmitIntoClient and add a comment about use of Lemire's nearly divisionless method (#38263)
1 parent b1b3249 commit 1ca4d7c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

stdlib/public/core/Random.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ extension RandomNumberGenerator {
104104
upperBound: T
105105
) -> T {
106106
_precondition(upperBound != 0, "upperBound cannot be zero.")
107+
// We use Lemire's "nearly divisionless" method for generating random
108+
// integers in an interval. For a detailed explanation, see:
109+
// https://arxiv.org/abs/1805.10941
107110
var random: T = next()
108111
var m = random.multipliedFullWidth(by: upperBound)
109112
if m.low < upperBound {

0 commit comments

Comments
 (0)