Last active
January 5, 2025 13:57
-
-
Save weihanglo/4d0c9879ccf49f64c79c1835326eb1d5 to your computer and use it in GitHub Desktop.
Revisions
-
weihanglo revised this gist
Jan 5, 2025 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,18 @@ pub struct XorShift64(u64); impl XorShift64 { pub const fn next(&mut self) -> u64 { let mut x = self.0; x ^= x << 13; x ^= x >> 7; x ^= x << 17; self.0 = x; x } } fn main() { let mut rng = XorShift64(123456789); for _ in 0..10 { println!("{}", rng.next()); } -
weihanglo revised this gist
Aug 26, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ impl XorShift64 { x ^= x >> 7; x ^= x << 17; self.a = x; x } } -
weihanglo revised this gist
Aug 26, 2020 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,16 @@ pub struct XorShift64 { a: u64, } impl XorShift64 { pub fn next(&mut self) -> u64 { let mut x = self.a; x ^= x << 13; x ^= x >> 7; x ^= x << 17; self.a = x; x } } fn main() { -
weihanglo revised this gist
Aug 26, 2020 . No changes.There are no files selected for viewing
-
weihanglo created this gist
Sep 8, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ pub struct XorShift64 { a: u64, } impl XorShift64 { pub fn next(&mut self) -> u64 { let mut x = self.a; x ^= x << 13; x ^= x >> 7; x ^= x << 17; self.a = x; x } } fn main() { let mut rng = XorShift64 { a: 123456789 }; for _ in 0..10 { println!("{}", rng.next()); } }