KEMBAR78
Try improved method for generating bounded random integers · Issue #75395 · dotnet/runtime · GitHub
Skip to content

Try improved method for generating bounded random integers #75395

@danmoseley

Description

@danmoseley

swiftlang/swift#39143 (Apache license)

Currently we use a simple rejection loop for generating int/long in a range

and other overloads. It may be that the Swift algorithm above is faster.

(Note that our existing algorithm is dropping high bits of the raw random result to minimize the rejections. If we can avoid doing that possibly it would improve the distribution?).

(I'm ignoring our legacy seeded impl which prefers reproducibility)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions