bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

timersub is incorrect for small values


From: jur
Subject: timersub is incorrect for small values
Date: Fri, 21 Dec 2001 23:18:24 +0100 (CET)

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.

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);
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]