POV-Ray : Newsgroups : povray.general : Random integer : Re: Random integer Server Time
31 Oct 2024 21:25:39 EDT (-0400)
  Re: Random integer  
From: Thomas de Groot
Date: 1 Feb 2016 07:21:24
Message: <56af4dc4$1@news.povray.org>
On 1-2-2016 13:19, William F Pokorny wrote:
> On 02/01/2016 03:06 AM, Thomas de Groot wrote:
>> On 1-2-2016 3:10, clipka wrote:
>>> Am 01.02.2016 um 02:55 schrieb Mike Horvath:
>>>> How do I calculate a random integer between n and p, inclusively?
>>>
>>> floor( rand(R)*((p-n)+1) + 0.5 )
>>>
>>> should do the trick
>>>
>>
>> Why not this: int(RRand(n,p,R))
>>
> RRand(Min,Max,RandSeededStream) from rand.inc. To get the inclusive part
> of the request I think we need:
>
> int(RRand(n,p+(1-1e-6),R))
>
> or
>
> floor(RRand(n,p+(1-1e-6),R))
>
> Bill P.

Are the Min and Max not inclusive by default? I always got that impression.

-- 
Thomas


Post a reply to this message

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