POV-Ray : Newsgroups : povray.documentation.inbuilt : revisiting rand(...) : revisiting rand(...) Server Time
14 Apr 2024 22:07:59 EDT (-0400)
  revisiting rand(...)  
From: Kenneth
Date: 17 Jul 2018 06:30:00
Message: <web.5b4dc48985ccabb3a47873e10@news.povray.org>
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.)

Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.