Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: how to get a 64bit random number with rand() ?

by bliako (Monsignor)
on Mar 22, 2018 at 23:25 UTC ( [id://1211570]=note: print w/replies, xml ) Need Help??


in reply to Re^2: how to get a 64bit random number with rand() ?
in thread how to get a 64bit random number with rand() ?

my point lies somewhere else, but you are correct:

adding two 32-bit numbers may get you to, at most, a 33-bit number.

Read that as "add thirty-two 32-bit rands()" (Gaussian distribution) or "multiply two 32-bit rands()" (uniform-product distribution).

Adding is just one form of combining two values but it's perfect to demonstrate the caveats of "combining" rand()s and that not all forms of "combining" rand()s lead to the desirable effect.

bliako
  • Comment on Re^3: how to get a 64bit random number with rand() ?

Replies are listed 'Best First'.
Re^4: how to get a 64bit random number with rand() ?
by Anonymous Monk on Mar 23, 2018 at 15:38 UTC

    Read that as "add thirty-two 32-bit rands()"
    You sure about that?

    The issue of entropy distilling is a concern for random number generators. Various sources of randomness are mixed into the pool and typically some one-way hashing applied on the output.

    Unless if you're trying to write a PRNG yourself, you don't want to mix anything. The generator is essentially a stream (and implementing such via IO layers is actually very simple.) From a stream, one just consumes characters.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1211570]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found