Pseudo-random numbers/Xorshift star: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m →{{header|Raku}}: further simplification and in-lining |
→{{header|Go}}: Rely on implicit conversion from uint64 to uint32 rather than use a mask. |
||
Line 162: | Line 162: | ||
const CONST = 0x2545F4914F6CDD1D |
const CONST = 0x2545F4914F6CDD1D |
||
const mask32 = (1 << 32) - 1 |
|||
type XorshiftStar struct{ state uint64 } |
type XorshiftStar struct{ state uint64 } |
||
Line 176: | Line 175: | ||
x = x ^ (x >> 27) |
x = x ^ (x >> 27) |
||
xor.state = x |
xor.state = x |
||
return uint32((x * CONST) >> 32 |
return uint32((x * CONST) >> 32) |
||
} |
} |
||
Line 216: | Line 215: | ||
4 : 20007 |
4 : 20007 |
||
</pre> |
</pre> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |