Random number generator (device): Difference between revisions

Content added Content deleted
(Switch from draft to complete task)
Line 2: Line 2:


If your system has a means to generate random numbers involving not only a software algorithm (like the [[wp:/dev/random|/dev/random]] devices in Unix), show how to obtain a random 32-bit number from that mechanism.
If your system has a means to generate random numbers involving not only a software algorithm (like the [[wp:/dev/random|/dev/random]] devices in Unix), show how to obtain a random 32-bit number from that mechanism.

=={{header|Forth}}==
<lang forth>variable rnd

: randoms ( n -- )
s" /dev/random" r/o open-file throw
swap 0 do
dup rnd 1 cells rot read-file throw drop
rnd @ .
loop
close-file throw ;</lang>


=={{header|J}}==
=={{header|J}}==