Thread: How can I get a REAL RANDOM number?

  1. #1
    Unregistered
    Guest

    Question How can I get a REAL RANDOM number?

    Hello, guys:

    How could I ger a REAL RANDOM NUMBER in C Programming?
    Don't ask me to call the rand(), it is not Real-Random, it is fake!
    If possible, please write down the source code.
    Thank you very much!
    CAUTION: Real-Random means generate one number in certain range everytime without any regulation!!

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    A computer cannot think for itself. How can you tell a computer to pick a REAL random number. The best you will ever get is a pseudo-random number. You can vary the sequence of pseudorandom numbers produced by the rand() function by using srand() and seeding the generator with a different seed. If you are still insistent on going mad trying to do this then take a look at donald knuths art of computer programming vol.2 where he devotes a whole chapter to this problem.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    here is a really nice random number generator thats 4 time faster than rand and much more random...

    http://www.math.keio.ac.jp/~matumoto/emt.html
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  4. #4
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    Hi!

    If you are using linux, you could read "/dev/random" to get highly random numbers. But this can be quite slow (it is based on things like keyboard interrupts mouse interrupts, and network traffic; you can guess when it gets slow). But it's great for seeding good-quality pseudo-random generators!

    There's also a quicker version, called "/dev/urandom". This is based on the same principles as the generator of the url given by no-one, but it is reseeded regularly when there is enough data in the "/dev/random" pool.

    Some intel-chipsets have a built-in random number generator. (NOT kidding!).

    greetinx,
    alex

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    197
    You can write a program which does make random numbers based on keyboard inputs (with getch()).

    You can make your normal random generator have a wider range:

    (randomnumber*randomnumber*maxnumber)%maxvalue+1

    klausi
    When I close my eyes nobody can see me...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. adding a number to a number
    By bigmac(rexdale) in forum C Programming
    Replies: 11
    Last Post: 10-24-2007, 12:56 PM
  2. %16 with double
    By spank in forum C Programming
    Replies: 11
    Last Post: 03-05-2006, 10:10 PM
  3. How do I restart a random number sequence.
    By jeffski in forum C Programming
    Replies: 6
    Last Post: 05-29-2003, 02:40 PM
  4. random number
    By mrukok in forum C++ Programming
    Replies: 7
    Last Post: 03-16-2003, 08:04 PM
  5. Programming Puns
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 44
    Last Post: 03-23-2002, 04:38 PM