We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
@_alwaysEmitIntoClient
1 parent b1b3249 commit 1ca4d7cCopy full SHA for 1ca4d7c
stdlib/public/core/Random.swift
@@ -104,6 +104,9 @@ extension RandomNumberGenerator {
104
upperBound: T
105
) -> T {
106
_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
110
var random: T = next()
111
var m = random.multipliedFullWidth(by: upperBound)
112
if m.low < upperBound {
0 commit comments