Le 18-07-17 à 06:27, Kenneth a écrit :
> I'm wondering about the documentation for rand(...).
> It has stated for a long time that the values that rand produces are "between
> 0.0 and 1.0, inclusive." But in all my uses of it in scenes, the value never
> actually hits those exact values. (Some of my code would actually have a problem
> if that happened; but I've never encountered such a problem... which is why I
> now ignore the 'inclusivity.')
> On a whim, I ran some tests (with different seed(...) values)-- 10,000,000 tries
> each time. But I haven't yet seen a 1.0 or a 0.0 occur.
> #declare S = seed(17);
> #declare R = rand(S);
> #if(R = 0.0 | R = 1.0)
> #debug concat("\n","rand = ",str(R,1,6),"\n")
> Unless there *is* a one-in-a-gazillion chance of it happening (uh, like the
> decay of a proton, for example), I think the docs should say, "between 0.0 and
> 1.0, exclusive."
> (BTW, I tried to find the rand() entry in the online wiki, just to see if the
> info there has changed since the latest(?) POV-included documentation, but I
> didn't know where to look.)
All values are equally possible, including 0 and 1. The mantissa for a
float is about 52 bits IIRC, so, you have a 1 in 2^52 chances of getting
a 0 and the same of getting a 1. Very small but not zero chance.
Post a reply to this message