summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorPaul Eggert <eggert@Penguin.CS.UCLA.EDU>2018-09-05 16:19:47 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2018-09-05 16:21:42 -0700
commit67475a59e95919e2dbe25ae950450578afdfd0dc (patch)
tree2f5f53e83399678e19f3895383f057e032a1609b /lisp/emacs-lisp
parente932395656b80cc30ba3a53d83bddf57339aef7d (diff)
downloademacs-67475a59e95919e2dbe25ae950450578afdfd0dc.tar.gz
emacs-67475a59e95919e2dbe25ae950450578afdfd0dc.tar.bz2
emacs-67475a59e95919e2dbe25ae950450578afdfd0dc.zip
Fix timer.el minor rounding error
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time): Fix rounding error by using integers rather than floats. * test/lisp/emacs-lisp/timer-tests.el (timer-test-multiple-of-time): New test.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/timer.el10
1 files changed, 5 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 795554fec58..74d37b0eaed 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -102,14 +102,14 @@ fire each time Emacs is idle for that many seconds."
"Yield the next value after TIME that is an integral multiple of SECS.
More precisely, the next value, after TIME, that is an integral multiple
of SECS seconds since the epoch. SECS may be a fraction."
- (let* ((trillion 1e12)
+ (let* ((trillion 1000000000000)
(time-sec (+ (nth 1 time)
- (* 65536.0 (nth 0 time))))
+ (* 65536 (nth 0 time))))
(delta-sec (mod (- time-sec) secs))
- (next-sec (+ time-sec (ffloor delta-sec)))
- (next-sec-psec (ffloor (* trillion (mod delta-sec 1))))
+ (next-sec (+ time-sec (floor delta-sec)))
+ (next-sec-psec (floor (* trillion (mod delta-sec 1))))
(sub-time-psec (+ (or (nth 3 time) 0)
- (* 1e6 (nth 2 time))))
+ (* 1000000 (nth 2 time))))
(psec-diff (- sub-time-psec next-sec-psec)))
(if (and (<= next-sec time-sec) (< 0 psec-diff))
(setq next-sec-psec (+ sub-time-psec