in reply to Re^2: inclusive rand
in thread inclusive rand

Unfortunately, Math::Random::Secure's dependencies have many sub-dependencies.

use strict; use warnings; use Math::Random::Secure 'irand'; # Random number between 0 and 1 inclusive (total 524288-1 numbers). sub custom_rand { irand(524288) / 524287; } printf("%f\n", custom_rand()) for 1 .. 20;

Regards, Mario.

Edit: Applied correction. Thanks pryrt.

Replies are listed 'Best First'.
Re^4: inclusive rand
by pryrt (Abbot) on Mar 13, 2017 at 15:28 UTC

    Since irand($n) returns [0,$n) => [0,$n-1] -- ie, not including $n -- you would have to divide by 524287 to get [0,1] inclusive.

      Thank you, pryrt. I applied the correction.