in reply to Re^2: Old random number generator
in thread Old random number generator
It outputs 023647263525973192use warnings; use strict; my_srand(0); print int(my_rand(99)) for 0..9; sub my_srand { use Win32::API; my $srand = Win32::API::More->new( 'msvcrt', 'void srand(unsigned int seed)' ) or die "Error: ".Win32::FormatMessage(Win32::GetLastError()); $srand->Call($_[0]); } sub my_rand { my $rand = Win32::API::More->new( 'msvcrt', 'int rand()' ) or die "Error: ".Win32::FormatMessage(Win32::GetLastError()); return int(($rand->Call()) * $_[0] / 32767); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Old random number generator
by Pascal666 (Scribe) on May 10, 2020 at 04:45 UTC | |
by syphilis (Archbishop) on May 10, 2020 at 06:47 UTC | |
|
Re^4: Old random number generator
by bliako (Abbot) on May 10, 2020 at 09:54 UTC |