Pseudo-random numbers/Xorshift star: Difference between revisions
Content added Content deleted
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: | Line 381: | ||
has $!state; |
has $!state; |
||
⚫ | |||
constant mask64 = 2⁶⁴ - 1; |
|||
constant const = 0x2545F4914F6CDD1D; |
|||
⚫ | |||
method next-int { |
method next-int { |
||
$!state +^= $!state +> 12; |
$!state +^= $!state +> 12; |
||
$!state +^= $!state +< 25 +& |
$!state +^= $!state +< 25 +& (2⁶⁴ - 1); |
||
$!state +^= $!state +> 27; |
$!state +^= $!state +> 27; |
||
($!state * |
($!state * 0x2545F4914F6CDD1D) +> 32 +& (2³² - 1) |
||
} |
} |
||
method next-rat { self.next-int / 2³² } |
method next-rat { self.next-int / 2³² } |
||
} |
} |
||
# Test next-int |
# Test next-int |