NAME

Math::Rand48 - perl bindings for drand48() family of random functions

SYNOPSIS

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);

DESCRIPTION

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
erand48($seed)

Return float value in range [0.0,1.0). Multiple independent streams of numbers can be obtained using erand48.

lrand48
nrand48($seed)

Return integer in range [0,2**31). Multiple independent streams of numbers can be obtained using nrand48.

mrand48
jrand48($seed)

Return integer in range [-2**31,2**31). Multiple independent streams of numbers can be obtained using jrand48.

Seed values

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.

AUTHOR

Nick Ing-Simmons <nick@ni-s.u-net.com>