LoginLogin

Can RNDF() return 0?

Root / General / [.]

12Me21Created:
RNDF() returns a random number >=0 and <1. It's technically possible for it to be 0, but this is EXTREMELY rare. If someone can find a situation where RNDF() returns 0, they'll win a prize. It has to be repeatable, like:
RANDOMIZE 0,14522
TEMP = RND(7)
PRINT RNDF()
Good luck.

RANDOMIZE 0,14532
FOR I=0 TO 3
 IF RNDF() THEN ENDIF
NEXT
?RNDF()

RANDOMIZE 0,14532
FOR I=0 TO 3
 IF RNDF() THEN ENDIF
NEXT
?RNDF()
Close, but:
RANDOMIZE 0,14532
FOR I=0 TO 3
 IF RNDF() THEN ENDIF
NEXT
?FORMAT$("%.9F",RNDF()) '0.000000003

Maybe-
RANDOMIZE 0,55219
FOR I=0 TO 2768
 IF RNDF() THEN ENDIF
NEXT
?FORMAT$("%.9F",RNDF())
'0.000000000

Just check if it's actually equal to 0. That's 0.00000000019.

Oh... now I see the impossibility of RNDF() ever returning exactly zero. I've gotten it to return up to 25+ random decimal places. And even if all of those just happened to be zero, at least to my findings, the number will just be shifted down about another 18 decimal places (essentially making no progress).

If we assume that the source of randomness in SB is a pseudorandom bit generator, then the odds are something like 1 to 2^52 of getting a zero. We don't know this definitely though and I'm just going off limited knowledge so the challenge is just finding the right seed. It's possible that there isn't a seed that gets zero on the first try but I don't know enough to say so.

The number of floats in [0,1) is 2^52 * 1023 + 1 Anyway, I've checked and otyaSB's random number generator appears to act identically to SB's, so that might be a good way to find out how SB works.

pfff just do
?RNDF() * 0

I got it.
PRINT "RNDF()=0"

Don't know if this counts, but theoretically, RNDF() will always return 0 when the program ends with this code:
NUM=1
WHILE NUM!=0
 NUM=RNDF()
WEND
Basically this program will run over and over again until RNDF() returns 0, so it's (technically) repeatable, but it will take a REALLY long time for it to do so.