Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Mar 21, 2018 at 18:06 UTC ( [id://1211446]=note: print w/replies, xml ) Need Help??


in reply to how to get a 64bit random number with rand() ?

Here's one way on a 64-bit capable build, provided your prng can produce at least 8-bit rands:

sub rand64{ unpack 'Q', pack 'C8', map rand(256), 1 .. 8; } for(1..10){ my $rand64 = rand64(); printf "%64s %16s %I64U\n", unpack( 'b64', pack( 'Q', $rand64 ) ), unpack( 'H16', pack( 'Q', $rand64 ) ), $rand64; } 1010111111000000011010001011001101101010011001011110100101011101 f5031 +6cd56a697ba 13445398104276075509 1011010011110001101111011011100010001000001100000001011101111110 2d8fb +d1d110ce87e 9144572311028731693 1100000000001011011000101111011110001110110110001110000000101001 03d04 +6ef711b0794 10666524418609958915 1000101001111110010101010010011101000111000011010101100000110110 517ea +ae4e2b01a6c 7789732994036170321 0010010000011010010011110001100000111110001011000100110111110011 2458f +2187c34b2cf 14966082219304704036 1111100110000001010110000110011011011100010010001001000100101101 9f811 +a663b1289b4 13008949044961771935 1001111000111111101110010111001111010011011111001110101110101100 79fc9 +dcecb3ed735 3879638649068715129 0000010011010010001110011101111101011111001001110101001011100101 204b9 +cfbfae44aa7 12054699119224834848 1110111000010100001101010110011111010011111011000100010111100011 7728a +ce6cb37a2c7 14385121508662716535 0011110011100110111011000101100110100100100110101101011101011000 3c673 +79a2559eb1a 1939742082549114684

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found