[glib] Fix off-by-1000 for GTimer



commit a70ba9c8b15451a8722aebfb64232bd18abf0a79
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sun Nov 21 21:59:57 2010 -0500

    Fix off-by-1000 for GTimer
    
    Divide monotonic time by 1e6 not 1e9 to get seconds.

 glib/gtimer.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtimer.c b/glib/gtimer.c
index 04f830c..0395fb0 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -233,10 +233,10 @@ g_timer_elapsed (GTimer *timer,
 
   elapsed = timer->end - timer->start;
 
-  total = elapsed / 1e9;
+  total = elapsed / 1e6;
 
   if (microseconds)
-    *microseconds = (elapsed / 1000) % 1000000;
+    *microseconds = elapsed % 1000000;
 
   return total;
 }



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