Hi Scott, Yes, the function, as it is written, is [min, max]....sorry about my typo.
If the intent of this function is, as you say, is [min, max], then the comment needs to change so there is no ambiguity. It's nit-picking, but I always assume a get_random is [min, max), which can be used for indexing arrays randomly. (That's how I discovered this on a crash). Chris. ----- Original Message ----- From: "Scott" <[EMAIL PROTECTED]> To: "OpenSceneGraph Users" <osg-users@lists.openscenegraph.org> Sent: Thursday, January 31, 2008 10:14 AM Subject: Re: [osg-users] get_random > On Jan 31, 2008 11:09 AM, Alberto Luaces <[EMAIL PROTECTED]> wrote: >> I think it was more important for the original writer to get high quality >> random numbers than to match the exact range. Maybe the documentation >> should >> be changed in order to say that it returns min < x <= max, or the >> function, >> decrementing the max arg passed one unit, so the value returned could be >> min >> < x <= max-1 which would mean min < x < max when dealing with integers. >> > > Matching the exact range is extremely important, as otherwise you can > get weird bugs when you get the values outside, which will happen > exceeding rarely, making them very hard to debug. > > Also, if the implementation really is >> minimum + (maximum - minimum) * rand() / RAND_MAX; > then the range is neither (min,max] nor (min,max) -- it's [min,max] > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org