Anonymous user
Linear congruential generator: Difference between revisions
m
→{{header|REXX}}: used variables to hold a couple of powers of 2, added/changed comments and whitespace, used whitespace in the two centered output titles.
MaiconSoft (talk | contribs) No edit summary |
m (→{{header|REXX}}: used variables to hold a couple of powers of 2, added/changed comments and whitespace, used whitespace in the two centered output titles.) |
||
Line 2,689:
/*──────────── number generators. BSD= 0 ──► (2**31)-1 MS= 0 ──► (2**16)-1 */
numeric digits 20 /*use enough dec. digs for the multiply*/
two@@16= 2**16 /*use a variable to contain 2^16 */
two@@31= 2**31 /* " " " " " 2^32 */
say center(' seed='seed" ", 79,
/* [↓] show 20 rand #'s for each seed.*/
bsd = (1103515245 * bsd + 12345) //
ms = ( 214013 * ms + 2531011) //
say ' state' right(j,3) " BSD" right(bsd, 11) left('', 13),
" MS" right( ms, 11) left('', 5),
" rand" right(ms %
end /*j*/
{{out|output|text= (shown at five-sixth size.) }}
<pre style="font-size:84%">
─────────────────────────────────── seed=0 ────────────────────────────────────
state 1 BSD 12345 MS 2531011 rand 38
state 2 BSD 1406932606 MS 505908858 rand 7719
Line 2,725 ⟶ 2,727:
state 19 BSD 996984527 MS 196417061 rand 2997
state 20 BSD 1157490780 MS 962080852 rand 14680
─────────────────────────────────── seed=1 ────────────────────────────────────
state 1 BSD 1103527590 MS 2745024 rand 41
state 2 BSD 377401575 MS 1210316419 rand 18467
|