POV-Ray : Newsgroups : povray.programming : random numbers in c++ Server Time
19 Apr 2024 12:20:54 EDT (-0400)
  random numbers in c++ (Message 11 to 11 of 11)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: random numbers in c++
Date: 26 Aug 2010 05:34:10
Message: <4c763512@news.povray.org>
Anthony D. Baye <Sha### [at] spamnomorehotmailcom> wrote:
> I was getting hinky results when calling srand48(time(NULL)), but it turns out
> that the solution was to call it once at the beginning of the program, rather
> than every time I called my Random() function...

  Well, think about it a bit. time() returns the amount of seconds since
some starting time. You are using that value to tell the random number
generator "start from here".

  If you do it again in less than a second, you will be again telling the
random number generator "start from here" (ie. the exact same number). What
do you expect to happen?

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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