in reply to Re^2: Randomizing Large Integers
in thread Randomizing Large Integers

15 bit of the input or of the output?

I get the following behavior that lets me assume that 32 bit random integers work:

# perl -e 'printf "%010x\n", int rand 2**16' 00000052e2 # perl -e 'printf "%010x\n", int rand 2**32' 006f7ae0c5 # perl -e 'printf "%010x\n", int rand 2**64' 00ffffffff

i.e. rand 2**N seems to return a N bit random integer, up to N = 32 but not above.

Replies are listed 'Best First'.
Re^4: Randomizing Large Integers
by BrowserUk (Patriarch) on May 19, 2008 at 21:25 UTC
Re^4: Randomizing Large Integers
by ikegami (Patriarch) on May 20, 2008 at 16:59 UTC

    15 bit of the input or of the output?

    15 bits of entropy. For a given argument, rand will only spit out 215 different results (spread over the requested range).