NAME
Math::BigInt::Random -- arbitrary sized random integers
DESCRIPTION
Random number generator for arbitrarily large integers.
Uses the Math::BigInt module to handle the generated values.
This module exports a single function called random_bigint, which returns
a single random Math::BigInt number of the specified range or size.
SYNOPSIS
use Math::BigInt;
use Math::BigInt::Random qw/ random_bigint /;
print "random by max : ", random_bigint( max => '10000000000000000000000000'), "\n",
"random by max and min : ",
random_bigint( min => '7000000000000000000000000', max => '10000000000000000000000000'), "\n",
"random by length (base 10): ",
random_bigint( length => 20 ), "\n",
"random by length (base 16) :",
random_bigint( as_hex => 1, length => 20)->as_hex, "\n";
FUNCTION ARGUMENTS
This module exports a single function called random_bigint, which returns a single random Math::BigInt of arbitrary size.
Parameters to the function are given in paired hash style:
max => $max,
the maximum integer that can be returned. Either the 'max' or the 'length'
parameter is mandatory. If both max and length are given, only the 'max'
parameter will be used.
min => $min,
which specifies the minimum integer that can be returned. Note that the
min should be >= 0.
length => $required_length,
which specifies the number of digits (with most significant digit not 0).
Note that if max is specified, length will be ignored. However, if max is
not specified, length is a required argument.
length_hex => 1,
which specifies that, if length is used, the length is that of the base 16
number, not the base 10 number which is the default for the length.
AUTHOR
William Herrera (wherrera@skylightview.com)
COPYRIGHT
Copyright (C) 2007 William Hererra. All Rights Reserved.
This module is free software; you can redistribute it and/or mutilate it
under the same terms as Perl itself.