Say t = 8.376600;
If I calculate tv by:
tv->tv_sec = (long) floor (time);
tv->tv_usec = (long) ((time - tv->tv_sec) * 1000000);
Then tv->tv_sec == 8 and tv->tv_usec == 376599.
printf("%f %ld.%06ld\n", time, tv->tv_sec, tv->tv_usec); prints
8.376600 8.376599.
Is there any simple way I can make the two outputs identical ?