delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
X-Received: | by 10.224.41.145 with SMTP id o17mr10768089qae.3.1373258047384; |
Sun, 07 Jul 2013 21:34:07 -0700 (PDT) | |
X-Received: | by 10.50.126.33 with SMTP id mv1mr1001245igb.1.1373258047350; Sun, |
07 Jul 2013 21:34:07 -0700 (PDT) | |
Newsgroups: | comp.os.msdos.djgpp |
Date: | Sun, 7 Jul 2013 21:34:06 -0700 (PDT) |
In-Reply-To: | <201307080352.r683qpTu018327@delorie.com> |
Complaints-To: | groups-abuse AT google DOT com |
Injection-Info: | glegroupsg2000goo.googlegroups.com; posting-host=71.34.83.153; posting-account=jrLHRgkAAABPV01ZW_RN_U6Tm5UnYNUx |
NNTP-Posting-Host: | 71.34.83.153 |
References: | <fd60497c-48ca-47ee-aefa-191f026fd3c1 AT googlegroups DOT com> |
<201307072036 DOT r67KanNk031567 AT delorie DOT com> <930fe945-22b9-4000-80fc-e42858b8f498 AT googlegroups DOT com> | |
<201307080318 DOT r683IKof016817 AT delorie DOT com> <5fbc6fac-c8c5-4bc7-8dc5-9b6b740b24c6 AT googlegroups DOT com> | |
<201307080352 DOT r683qpTu018327 AT delorie DOT com> | |
User-Agent: | G2/1.0 |
MIME-Version: | 1.0 |
Message-ID: | <cb6c1ce7-8edd-4438-8352-92be723d0f09@googlegroups.com> |
Subject: | Re: CLOCKS_PER_SEC of time.h doesn't work to prove it is a value for |
one second | |
From: | "K.J.Williams" <lordwilliams1972 AT gmail DOT com> |
Injection-Date: | Mon, 08 Jul 2013 04:34:07 +0000 |
X-Received-Bytes: | 2469 |
Bytes: | 2686 |
Lines: | 37 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
On Sunday, July 7, 2013 8:52:51 PM UTC-7, DJ Delorie wrote: > > Does clock() in DJGPP wrap around after a certain amount of seconds > > > elapsed as stated by that website that I quoted above? > > > > Because of the way DOS ticks work, clock() is not supposed to be used > > across two midnights. As long as you call it at least once per day, > > it should wrap normally every 17 months or so. I changed the code to this: #include<time.h> #include<stdio.h> int main(void) { clock_t ticks1, ticks2; ticks1=0; ticks2=ticks1; while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<100) { ticks2 += 5; //printf("%ld\n",(ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)); } printf("Took %ld ticks to wait one second.\n",(ticks2-ticks1)/100); printf("This value should be the same as CLOCKS_PER_SEC which is %ld.\n",CLOCKS_PER_SEC); return 0; } .. since you have to have the ticks increment by 5, until its 100. Then you have to divide 9100 ticks by 100 to show that it is actually 91 ticks per second.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |