|
From: Per W. <pw...@ia...> - 2003-06-19 00:49:24
|
I'm not so sure about your definition of time(). time_t is a type - might be int, long, struct xx, ... depending on implementation and processor register width etc. However, without checking the latest c++ standard, time() returns time in seconds since epoch (seconds since 1969). With a resolution of one second, it is definitely possible to call time() multiple times and get the same return value. /Per W Yes, two calls to time() within the same second will retu On Thu, 19 Jun 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: dev...@li... > > [mailto:dev...@li...] On Behalf > > Of Sudhir K KRISHNAWARRIER > > Sent: Thursday, June 19, 2003 1:10 AM > > To: dev...@li... > > Subject: RE: [Dev-C++] rand() > > > > May be it is a little better to use the time in > > micro/milliseconds in some form as the seed instead of time > > (NULL) which returns seconds. This will make sure that two > > instances of the program started almost the same time will > > not get the same random number sequence. In SVR4/BSD, > > gettimeofday will do the trick but not sure what is the POSIX > > way of getting microseconds. > > > time() is not returning seconds it is returning time_t which can be whatever > the implementation wants. Two subsequent calls of time() cannot return the > same value since it represents the calendar time (day. month, year, hour, > minutes, seconds...). > > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |