Skip to content

Commit

Permalink
cleanup import presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokathor committed Aug 31, 2023
1 parent a90764b commit d5cffec
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
//! will have *slightly* better randomness quality than the lower bits.
//! * At your option, import the [Gen32] trait for various extension methods.

mod bounded_rand;
pub use bounded_rand::*;
pub mod formulas;
use formulas::ieee754_random_f32;

mod pcg;
use formulas::ieee754_random_f32;
pub use pcg::*;

pub mod formulas;
mod bounded_rand;
pub use bounded_rand::*;

/// A trait for pseudo-random number generators with 32-bit output per step.
pub trait Gen32 {
Expand Down Expand Up @@ -55,8 +55,8 @@ pub trait Gen32 {
/// Gives a value in the range `1..=4`
#[inline]
fn d4(&mut self) -> i32 {
let base = BoundedRandU16::_4.sample(|| (self.next_u32() >> 16) as u16);
i32::from(base) + 1
let base = self.next_u32() >> 30;
base as i32 + 1
}

/// Gives a value in the range `1..=6`
Expand All @@ -69,8 +69,8 @@ pub trait Gen32 {
/// Gives a value in the range `1..=8`
#[inline]
fn d8(&mut self) -> i32 {
let base = BoundedRandU16::_8.sample(|| (self.next_u32() >> 16) as u16);
i32::from(base) + 1
let base = self.next_u32() >> 29;
base as i32 + 1
}

/// Gives a value in the range `1..=10`
Expand Down

0 comments on commit d5cffec

Please sign in to comment.