Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found