https://github.com/not-fl3/quad-rand
https://github.com/not-fl3/quad-rand
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/not-fl3/quad-rand
- Owner: not-fl3
- Created: 2020-03-18T15:44:21.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-03T15:59:43.000Z (about 2 months ago)
- Last Synced: 2025-03-29T15:05:01.127Z (26 days ago)
- Language: Rust
- Size: 15.6 KB
- Stars: 14
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-quads - quad-rand - wasm-friendly random number generator for quads. (Libraries / Libraries: Other)
README
# quad-rand
[](https://crates.io/crates/quad-rand)
[](https://docs.rs/quad-rand)`quad-rand` implements the [SplitMix](https://doi.org/10.1145/2660193.2660195) pseudo-random number generator in a thread-safe manner.
Compatible with wasm and also no-std compatible.
Basic usage, no dependencies involved:
```rust
use quad_rand as qrand;// seed random
qrand::srand(12345);// get random number from 0 to u32::MAX
let x = qrand::rand();// get random number from given range
let x = qrand::gen_range(0., 1.);
assert!(x >= 0. && x < 1.);// gen_range works for most of standard number types
let x: u8 = qrand::gen_range(64, 128);
assert!(x >= 64 && x < 128);
```Optional compatibility layer with `rand` crate:
```rust
use quad_rand::compat::QuadRand;
use rand::seq::SliceRandom;let mut vec = vec![1, 2, 3, 4, 5, 6];
// QuadRand is rand::RngCore implementation, allowing to use all the cool stuff from rand
vec.shuffle(&mut QuadRand);```