POV-Ray : Newsgroups : povray.documentation.inbuilt : revisiting rand(...) : Re: revisiting rand(...) Server Time
16 Apr 2024 07:32:25 EDT (-0400)
  Re: revisiting rand(...)  
From: clipka
Date: 18 Jul 2018 09:18:43
Message: <5b4f3e33$1@news.povray.org>
Am 17.07.2018 um 22:11 schrieb Kenneth:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> Alain <kua### [at] videotronca> wrote:
>>> 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.
>> So then maybe round to the nearest Q decimal place to "compress" the range and
>> increase the likelihood of getting a 1 or a 0.
> Compressing the range is an interesting concept, that I wasn't aware of. I'll
> give some thought to the formula presented there. But I would suspect that
> POV-Ray's internal rounding would be *either* 'round up' OR 'round down', but
> not both (?) In other words, a 1.0 (but never a 0.0), OR a 0.0 (but never a
> 1.0).

While that's indeed the way most floating-point random number generators
work -- usually giving you a number ranging from 0.0 inclusive to 1.0
exclusive -- POV-Ray's SDL random number generator is designed to be
inclusive both fenceposts.

Post a reply to this message

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