Crates.io | weyl |
lib.rs | weyl |
version | 0.1.3 |
source | src |
created_at | 2019-08-09 12:22:17.823459 |
updated_at | 2019-08-09 14:14:05.635085 |
description | Middle Square Weyl Sequence RNG for Rust |
homepage | |
repository | https://github.com/tidwall/weyl-rs |
max_upload_size | |
id | 155350 |
size | 6,011 |
A new implementation of John von Neumann's middle square random number generator (RNG). A Weyl sequence is utilized to keep the generator running through a long period.
This library includes a few thread-safe functions.
weyl::u64() // generates a random u64
weyl::f64() // generates a random f64
weyl::fill(&mut bytes) // fill byte slice with random data
weyl::seed(my_seed) // reseed the number generator
There's also a Generator
type in case you need to generate random numbers in
an isolated thread. It's little faster because it avoids mutex locks.
let mut rand = weyl::Generator::new(my_seed);
println!("{}", rand.u64()); // generates a random u64
Josh Baker @tidwall
Weyl source code is available under the ISC License.