r4670: abartlet was worried about floating point precision with my first
authorAndrew Tridgell <tridge@samba.org>
Tue, 11 Jan 2005 03:26:26 +0000 (03:26 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:08:40 +0000 (13:08 -0500)
version - here is one based purely on 64 bit math
(This used to be commit 1ff04b0dc3e680b6288622576bb373359a594c2f)

source4/lib/time.c

index 92eb2dee5e1746d6b0d294124bba0454fe524516..fd005215a118c363a59fbce34442c8a086fa3875 100644 (file)
@@ -543,6 +543,6 @@ struct timeval timeval_diff(struct timeval *tv1, struct timeval *tv2)
 */
 NTTIME timeval_to_nttime(struct timeval *tv)
 {
-       double t1 = tv->tv_sec + (tv->tv_usec*1.0e-6);
-       return (t1 + TIME_FIXUP_CONSTANT) * 1.0e7;
+       return 10*(tv->tv_usec + 
+                 ((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
 }