[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: timersub is incorrect for small values
From: |
Andreas Jaeger |
Subject: |
Re: timersub is incorrect for small values |
Date: |
Fri, 28 Dec 2001 20:17:29 +0100 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Artificial Intelligence, i386-suse-linux) |
address@hidden writes:
> timersub is incorrect for small values, defined in sys/time.h
>
> i.e. 0.001000 - 0.001800 gives -1.999200, which is not what my calculator
> sais.
But 0.0010 is greater than 0.0018 - timersub expects that the
arguments are ordered.
Andreas
>
> Sample.c file below.
>
> Regards,
>
> Jurriaan
>
> #include <stdio.h>
> #include <sys/time.h>
>
> int main() {
> struct timeval a,b,c;
>
> a.tv_sec=0;
> a.tv_usec=1000;
>
> b.tv_sec=0;
> b.tv_usec=1800;
>
> timersub(&a,&b,&c);
>
> printf("lala: %ld.%.6ld\n",c.tv_sec,c.tv_usec);
> }
>
>
> _______________________________________________
> Bug-glibc mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-glibc
>
--
Andreas Jaeger
SuSE Labs address@hidden
private address@hidden
http://www.suse.de/~aj