Math::Rand48 - perl bindings for drand48() family of random functions
use Math::Rand48; my $n = drand48(); # Float value [0.0,1.0) my $seed = seed48(); # Get seed for drand48, lrand48, mrand48 my $m = erand48($seed); # Float value [0.0,1.0) - modifies $seed seed48($seed); # Set seed for drand48, lrand48, mrand48 use Math::Rand48 qw(lrand48); my $un = lrand48(); my $um = nrand48($seed);
This package provides an interface to the 48-bit family of random number functions, commonly provided on UNIX systems.
seed48
Returns the current seed used by drand48, lrand48, mrand48. If given an argument sets the seed to that value.
drand48
lrand48
mrand48
erand48
Return float value in range [0.0,1.0). Multiple independent streams of numbers can be obtained using erand48.
nrand48
Return integer in range [0,2**31). Multiple independent streams of numbers can be obtained using nrand48.
jrand48
Return integer in range [-2**31,2**31). Multiple independent streams of numbers can be obtained using jrand48.
The $seed above are perl scalars. When in use they are converted to 6 byte binary "strings". If the incoming value is a string of less then 6 bytes it is padded with 0xFF. If the incoming value is a string of more than 6 bytes it is "hashed" using perl's hash function to yield a 32 bit value which is then padded with two bytes of 0xFF. If the incoming value is an integer it is used for 4 bytes, with two bytes of 0xFF.
Nick Ing-Simmons <nick@ni-s.u-net.com>
To install Math::Rand48, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::Rand48
CPAN shell
perl -MCPAN -e shell install Math::Rand48
For more information on module installation, please visit the detailed CPAN module installation guide.