stdrandom 0.2.0

Generate random numbers using standard library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use stdrandom::random_u64;

#[test]
#[ignore]
fn main() {
    let mut hist_upper = [0; 16];
    let mut hist_lower = [0; 16];

    for _ in 0..300_000 {
        let num = random_u64();
        hist_upper[(num >> 60) as usize] += 1; // Highest 4 bits
        hist_lower[(num & 0xF) as usize] += 1; // Lowest 4 bits
    }

    println!("Upper bits distribution: {:?}", hist_upper);
    println!("Lower bits distribution: {:?}", hist_lower);
    panic!();
}