Message-Id: <3.0.5.32.19971125000726.00979ea0@hal.nt.tuwien.ac.at> Date: Tue, 25 Nov 1997 00:07:26 +0100 To: djgpp AT delorie DOT com From: Anton Helm Subject: strange behavior of difftime() Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Precedence: bulk Quote from the ANSI C Standard *): 7.12.2.2 The difftime function Synopsis #include double difftime(time_t time1, time_t time0); Description The difftime function computes the difference between two calendar times time1 - time0. Returns The difftime function returns the difference expressed in seconds as a double. End quote. From the above quote I would assume that there is no restriction on time0 and time1, especially the standard doesn't assume that time1 > time0. Why does difftime() from the DJGPP library produce erronous results if time0 > time1 ?????? difftime() should return a negative result, but actually it returns (double)(UINT_MAX - d) where d is the absolute value of the difference of time0 and time1. E.g. you get a positive difference of about 128 years if you set time1 to 1990 and time0 to 1997. *) ISO/IEC 9899:1990 p.171 ************************************************************** Dipl.-Ing. Anton HELM *T* mailto:tony AT nt DOT tuwien DOT ac DOT at Institut fuer *U* http://www.nt.tuwien.ac.at/~tony/ Nachrichtentechnik und *W* http://www.nt.tuwien.ac.at/ Hochfrequenztechnik *I* talkto:tony AT eagle DOT nt DOT tuwien DOT ac DOT at Guszhausstr. 25/389 *E* phoneto:+43-1-58801-3520 A-1040 Wien, AUSTRIA *N* faxto:+43-1-5870583 **************************************************************