https://github.com/bgrainger/romurandom
.NET implementation of Romu random number generators
https://github.com/bgrainger/romurandom
csharp netcore netstandard prng random-number-generators romu
Last synced: 5 months ago
JSON representation
.NET implementation of Romu random number generators
- Host: GitHub
- URL: https://github.com/bgrainger/romurandom
- Owner: bgrainger
- License: apache-2.0
- Created: 2020-03-03T05:01:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-06T06:41:20.000Z (over 6 years ago)
- Last Synced: 2024-12-31T01:27:35.459Z (over 1 year ago)
- Topics: csharp, netcore, netstandard, prng, random-number-generators, romu
- Language: C#
- Homepage: http://romu-random.org/
- Size: 32.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RomuRandom
RomuRandom is a .NET implementation of the [Romu](http://romu-random.org/) family of
random number generators.
[](https://github.com/bgrainger/RomuRandom/actions)
[](https://www.nuget.org/packages/RomuRandom)
## Usage
Use `RomuRandom` as a drop-in replacement for [`System.Random`](https://docs.microsoft.com/en-us/dotnet/api/system.random):
```csharp
System.Random random = new RomuRandom(); // seeded with current time
var randomNumber = random.Next();
var dieRoll = random.Next(6); // from 0-5
var randomInRange = random.Next(100, 200); // from 100-199
var bytes = new byte[100];
random.NextBytes(bytes); // fill array with random bytes
```
### Advanced
The `RomuDuo`, `RomuTrio`, and `RomuQuad` classes can be
instantiated directly (for higher performance, or more control
over the seed values).
Note that they only return a random `ulong` value in the range
`[0, UInt64.MaxValue]`. This needs to be converted carefully
if you want to get a random number in a smaller range without bias.
## License
Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).