Pseudo-random numbers/Xorshift star: Difference between revisions
Pseudo-random numbers/Xorshift star (view source)
Revision as of 16:51, 14 August 2020
, 3 years ago→{{header|Raku}}: further simplification and in-lining
Thundergnat (talk | contribs) m (→{{header|Raku}}: simplify, remove some superstitious parenthesis, only mask when necessary) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: further simplification and in-lining) |
||
Line 381:
has $!state;
▲ submethod BUILD ( Int :$seed where * > 0 = 1 ) { $!state = $seed +& mask64 }
method next-int {
$!state +^= $!state +> 12;
$!state +^= $!state +< 25 +&
$!state +^= $!state +> 27;
($!state *
}
method next-rat { self.next-int / 2³² }
}
# Test next-int
|