1

Is the following problem with Math::Random::Secure fixable? For numbers greater than 2^32, the results are in scientific notation; unlike most modules, the string terminator quotes '' and "" don't put this in normal integer form:

perl -MMath::Random::Secure -E "say rand(10**300)"
1.02799411703931e+299

perl -MMath::Random::Secure -E 'say rand("10**300")'
9.30305125498312e+299

I want my results to look like this, except much larger:

perl -MMath::Random::Secure -E 'say rand("10**12")'
200565369174.914

How can I get the full decimal expansion of these numbers rather than scientific notation?

ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
J. Linne
  • 275
  • 4
  • 15
  • 1
    This is confusing. The outputs are not integers, so there is no "bigint" format. Looking at `Math::Random::Secure`, I see no reason why you would be able to get anything other than a 32-bit pseudo-random integer at a time. Also, even under ideal conditions, the output is probably biased, because the module confuses floating point numbers with reals. Maybe you should revise the question to explain what your real goal is. – Sinan Ünür Oct 12 '16 at 13:14
  • 1
    s/bigint/"scientific notation"/g – mob Oct 12 '16 at 13:24

1 Answers1

1

You won't get the big numbers you are looking for. Math::Random::Secure is limited to 32-bit numbers. You'll need to use something else if you want larger numbers.

brian d foy
  • 129,424
  • 31
  • 207
  • 592