Hello all monks,

In the following code rand() doesn't even give me 52bit of data;
both MSB and LSBs are fixed !

what is the best way to get 64bit numbers ?

0000000000000000010111100101110000011011100101010001000000001111 00005 +E5C1B95100F 0000000000001100111011111010100001011001101001100011011101111111 000CE +FA859A6377F 0000000000000011001010100001010110101011101000101010001000101111 00032 +A15ABA2A22F 0000000000000110110100001111000101010110001101100010111100011111 0006D +0F156362F1F 0000000000001101001011001010011110010100111010001101000101001111 000D2 +CA794E8D14F 0000000000000101110101011101011111101000111011101111111110111111 0005D +5D7E8EEFFBF 0000000000000001000001010001000100101100100010010110010101101111 00010 +5112C89656F 0000000000001111110001100010010000001010111000101101000101011111 000FC +6240AE2D15F 0000000000000100100100001010101010101111001011110110011010001111 00049 +0AAAF2F668F 0000000000001100100011011000010010011010000101000000101111111111 000C8 +D849A140BFF 0000000000001101000011001100011010101101010100010001110010101111 000D0 +CC6AD511CAF 0000000000000010100111010110010110111101100011110101011110011111 00029 +D65BD8F579F 0000000000000000001100001110001000000110010000100000111111001111 00003 +0E206420FCF 0000000000000101001111111000100011111000000101011001110000111111 00053 +F88F8159C3F 0000000000000100100110101110000010010110100101010000011111101111 00049 +AE0969507EF 0000000000000100111011101101111101110011110101100000000111011111 0004E +EDF73D601DF 0000000000000110110111111000000010010010010011100000110100001111 0006D +F80924E0D0F 0000000000000111011111011100100001010101101101111111000001111111 00077 +DC855B7F07F 0000000000001110110001011111000001110111011001000110011100101111 000EC +5F07764672F 0000000000001101011110001010000111001010101101010001000000011111 000D7 +8A1CAB5101F
#!/usr/bin/perl $|++; srand(54321); for (1 .. 20) { my $n = int rand(0xF_FFFF_FFFF_FFFF); printf "\r%064b %016X\n",$n,$n; } exit $?;

In reply to how to get a 64bit random number with rand() ? by iglake

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.