Strange results from random
#1

I was just messing around with a few functions the other day and i thought id test how random random is lol so i made an infinite loop placed it in the funtion main (as i dont have gta on this pc) and i get some wierd results maybe im doing some realy stupid mistake but i can't see it. Someone might see whats wrong here it is.
pawn Код:
#include <a_samp>

main()
{
    new value;
    for(;;)
    {
        value = random(2);
        printf("%d",value);
    }
}
And the results
Код:
[20:10:50] 2 
[20:10:50] 3 
[20:10:50] 5 
[20:10:50] 7 
[20:10:50] 11 
[20:10:50] 13 
[20:10:50] 17 
[20:10:50] 19 
[20:10:50] 23 
[20:10:50] 29 
[20:10:50] 31 
[20:10:50] 37 
[20:10:50] 41 
[20:10:50] 43 
[20:10:50] 47 
[20:10:50] 53 
[20:10:50] 59 
[20:10:50] 61 
[20:10:50] 67 
[20:10:50] 71 
[20:10:50] 73 
[20:10:50] 79 
[20:10:50] 83 
[20:10:50] 89 
[20:10:50] 97
To my knowledge the maximum number should be 2.
Reply
#2

This loop never stops?
Reply
#3

It does stop so its not realy an infinite loop, but if that was in c++ it would loop untill the program is closed. I think the reason it stops is to do with the server itself, though i'm not sure. But why do i get values above 2? and why does it seem to count up?? it doesn't seem that random to me.

EDIT: no it doesn't stop it stopped for me because i made a silly mistake.
Reply
#4

...

Just ran this and got a constant of random 0's and 1's..

That's strange, something messed up on your pawno or something?

Reminds me of the failing if statement:

pawn Код:
new a = 1;
if (a == 1) {

} else {
This runs ......
}
Reply
#5

Код:
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 1
[16:51:59] 0
[16:51:59] 1
[16:51:59] 0
[16:51:59] 0
[16:51:59] 1
Works for me, and loop didn't stop.
Reply
#6

Hmm not to my knowledge everything else is fine. Ill attach my file now its wierd we get very different results i get the exact same result every time.

EDIT: It has to be something on my end but i can't imagine what its a fresh server i downloaded just 2 days ago not even done much scripting since i got it.
Reply
#7

Same..

pawn Код:
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
[16:58:14] 1
[16:58:14] 1
[16:58:14] 0
In 2 minutes I've had a 50 mb server log xD

Loop never ends.. maybe is your PC, pawno or SA-MP server package..
Reply
#8

Yes it must be as my loop does end, and i still get the same results. i thought that was strange myself because it shouldn't. Thanks for the response guys guess ill have to download a new one again ill try the mirror this time. oops there is no mirror lol

EDIT: Sorted lmao i did something very silly had an fs running that prints prime numbers what a wolly haha.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)