From: Gerd Moellmann Date: Fri, 5 Oct 2001 09:26:53 +0000 (+0000) Subject: (timer-relative-time): Fix computation for negative `micro'. X-Git-Tag: ttn-vms-21-2-B4~19759 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e5da45fda7e205a900dfa62236afa239bfcb534a;p=emacs.git (timer-relative-time): Fix computation for negative `micro'. --- diff --git a/lisp/timer.el b/lisp/timer.el index 3820b57365e..0c159c6023d 100644 --- a/lisp/timer.el +++ b/lisp/timer.el @@ -116,9 +116,11 @@ SECS may be a fraction." (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))))