POV-Ray : Newsgroups : povray.general : Random integer : Re: Random integer Server Time
16 May 2024 14:24:28 EDT (-0400)
  Re: Random integer  
From: William F Pokorny
Date: 1 Feb 2016 07:19:14
Message: <56af4d42$1@news.povray.org>
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.


Post a reply to this message

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