need code to gen all bit possibilities for 64 bits

Tim Roberts timr at probo.com
Thu May 31 03:19:36 EDT 2001


"Bryan Webb" <bww00 at amdahl.com> wrote:

>Hi,
>    I need code to generate  bit configs for 64 bits. I know that this could
>be big. I would like to be able to start and stop at a certain point and
>write the results to a file to input to another program.

The easiest way to generate all possible 64-bit patterns is to count:

i = 0L
while i < (2L ** 64L): print i

Printing 18 quintillion numbers is going to take a very, very, VERY long
time.  At one per microsecond, I get about 500,000 years.

Are you looking for RANDOM 64-bit patterns?  You didn't say that.  You can
use a simple linear congruential generator:

  seed = 1234567890L

  def LongRand():
    seed = seed * 134775813L + 1
    return seed

--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list