Page 1 of 1

Bug in Rnd()

Posted: Thu Jul 16, 2026 9:05 pm
by Bugala
windows 11, Hollywood 11, seems to be having a problem with Rnd()-function. Havent noticed this before, since I didnt check its working before.

Today happened to be checking if my small code worked right, and noticed Random itself wasnt working properly.

Here is video showing the problem:
https://youtube.com/shorts/dD1xpWSUruk?feature=share

In this video I have one line of code:

Code: Select all

Debigprint(Rnd(13))
I keep continously clicking the "run" button to run the program, and as you can see, the result isnt really random at all, but it seems like there is some slow timer that keeps going down, and result is based upon what time it is in that slow timer.

As in, if I click slowly result will be in way of 9, 6, 3.

If I keep clicking fast the "run"-button, then result is 9, 9, 9, 8, 8, 7, 7, 7

Re: Bug in Rnd()

Posted: Thu Jul 16, 2026 10:27 pm
by plouf
i think its known, that why RndStrong() has been created

Re: Bug in Rnd()

Posted: Thu Jul 16, 2026 11:04 pm
by Bugala
No, even Rnd() is less random than RndStrong(), Rnd() should still feel like random.

If you look at the video, the Rnd() is not random at all anymore in the test, but when doing it multiple times, I can predict its outcome.

Although, now that I tested:

Code: Select all

For n = 1 To 10
	DebugPrint(Rnd(10))
Next
It appears only the first Rnd(10) is predictable, rest of the Rnd(10) are random enough to be said to be random.

By otherwords, solution to the problem that I had, would have been to do Rnd() twice, and take only the next Rnd() result into account.