| View previous topic :: View next topic |
| Author |
Message |
goldengold Grandmaster Cheater Supreme
Reputation: -1
Joined: 11 Nov 2006 Posts: 1841 Location: -.-
|
Posted: Thu Nov 08, 2007 4:42 am Post subject: Generating a random number? |
|
|
I jsut read somewhere that it said it was impossible ofr a computer to generate a random number.
Like just say generaterandomnumber()
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Thu Nov 08, 2007 4:48 am Post subject: |
|
|
srand();
rand(time(NULL));
|
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Thu Nov 08, 2007 4:52 am Post subject: |
|
|
| Well, It's not exactly random, but very close to it. it depends on the time the function is called, which is not that random in some cases. Still, it's good enough for anything you need
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Thu Nov 08, 2007 5:17 am Post subject: |
|
|
a random number CAN have parameters.
Say i want a randnum between 1 and 23232323. Even if i make it so it will be in those, its still random because the computer is not given an initial value.
_________________
|
|
| Back to top |
|
 |
AtheistCrusader Grandmaster Cheater
Reputation: 6
Joined: 23 Sep 2006 Posts: 681
|
Posted: Thu Nov 08, 2007 6:20 am Post subject: |
|
|
| text 1 = Rnd(999 * rnd)
|
|
| Back to top |
|
 |
Hackerdevelopment Advanced Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 55
|
Posted: Thu Nov 08, 2007 6:45 am Post subject: |
|
|
Wat kind of programming?
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu Nov 08, 2007 9:52 am Post subject: |
|
|
| noz3001 wrote: | srand();
rand(time(NULL)); |
int random;
srand(time(NULL));
random = rand();
|
|
| Back to top |
|
 |
goldengold Grandmaster Cheater Supreme
Reputation: -1
Joined: 11 Nov 2006 Posts: 1841 Location: -.-
|
Posted: Thu Nov 08, 2007 10:12 am Post subject: |
|
|
Lol k thanks. btw im not programming anything. (couldn't even if i wanted to.)
But i found a TUT for kids which is alot easier than the other books ive read so yay
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Thu Nov 08, 2007 10:12 am Post subject: |
|
|
Too easy to see the pattern from GetTickCount. Use CryptGenRandom or Boost::Random
_________________
|
|
| Back to top |
|
 |
|