Pseudo-random numbers/Splitmix64: Difference between revisions

Added Quackery.
m (syntax highlighting fixup automation)
(Added Quackery.)
Line 1,004:
16408922859458223821
{0: 20027, 1: 19892, 2: 20073, 3: 19978, 4: 20030}</pre>
 
=={{header|Quackery}}==
 
Note that Quackery does not have floating point, so this code uses rational numbers and approximates them to 16 places after the decimal point (when displayed as decimal fractions), so is at least as good as 64 bit floating point.
 
<syntaxhighlight lang="Quackery"> [ $ "bigrat.qky" loadfile ] now!
 
[ stack hex DEFACEABADFACADE ] is state ( --> s )
 
[ state replace ] is seed ( n ---> )
 
[ state take
hex 9E3779B97F4A7C15 + 64bits
dup state put
dup 30 >> ^
hex BF58476D1CE4E5B9 * 64bits
dup 27 >> ^
hex 94D049BB133111EB * 64bits
dup 31 >> ^ ] is nextint ( --> n )
 
[ nextint
hex 10000000000000000
10000000000000000 round ] is nextfrac ( --> n/d )
 
1234567 seed
5 times [ nextint echo cr ]
cr
987654321 seed
' [ 0 0 0 0 0 ]
100000 times
[ nextfrac 5 1 v* proper 2drop
2dup peek 1+ unrot poke ]
echo</syntaxhighlight>
 
{{out}}
 
<pre>6457827717110365317
3203168211198807973
9817491932198370423
4593380528125082431
16408922859458223821
 
[ 20027 19892 20073 19978 20030 ]</pre>
 
=={{header|Raku}}==
1,462

edits