diff lisp/timer.el @ 39558:88e97e81d728

(timer-relative-time): Fix computation for negative `micro'.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 05 Oct 2001 09:26:53 +0000
parents 253f761ad37b
children 534629ca4cc4
line wrap: on
line diff
--- a/lisp/timer.el	Fri Oct 05 09:26:17 2001 +0000
+++ b/lisp/timer.el	Fri Oct 05 09:26:53 2001 +0000
@@ -116,9 +116,11 @@
     (setq low (+ low (floor secs)))
 
     ;; Normalize
-    (setq low (+ low (/ micro 1000000)))
+    ;; `/' rounds towards zero while `mod' returns a positive number,
+    ;; so we can't rely on (= a (+ (* 100 (/ a 100)) (mod a 100))).
+    (setq low (+ low (/ micro 1000000) (if (< micro 0) -1 0)))
     (setq micro (mod micro 1000000))
-    (setq high (+ high (/ low 65536)))
+    (setq high (+ high (/ low 65536) (if (< low 0) -1 0)))
     (setq low (logand low 65535))
 
     (list high low (and (/= micro 0) micro))))