POV-Ray : Newsgroups : povray.general : random numbers : Re: random numbers Server Time
8 Aug 2024 20:25:01 EDT (-0400)
  Re: random numbers  
From: Pascal Baillehache
Date: 5 Oct 2000 15:56:00
Message: <39dcdcd0$1@news.povray.org>
Many thanks,
it doesn't matter it's not the best one, I just need to compute exactly the
same one in a C++ code for a test ...
Baillp


slr### [at] fwicom...
> On Thu, 5 Oct 2000 15:43:18 +0200, Pascal Baillehache wrote:
> >Hi all
> >what I need is the exact algorithm used in the POV rand() function, where
> >can I found this ?
>
> In the source code.  Specifically, the function stream_rand() in
express.c.
> It's short, so I'll quote it here.  Note that it isn't the best prng in
the
> world, and it probably fails whole truckloads of tests for randomness, but
> remember that it was added almost as an afterthought to 3.0 and hasn't
been
> thought of much since then.  Anyway, here ya go:
>
> static DBL stream_rand(int stream)
> {
>   next_rand[stream] = next_rand[stream] * 1812433253L + 12345L;
>
>   return((DBL)(next_rand[stream] & 0xFFFFFFFFUL) / 0xFFFFFFFFUL);
> }
>
>
> --
> Ron Parker   http://www2.fwi.com/~parkerr/traces.html
> My opinions.  Mine.  Not anyone else's.
> Proudly not helping RIAA and SDMI steal my rights --
>   http://www.eff.org/Misc/EFF/Newsletters/EFFector/HTML/effect13.08.html


Post a reply to this message

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