emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master ee76efd 12/17: Fix rounding error


From: Oleh Krehel
Subject: [elpa] master ee76efd 12/17: Fix rounding error
Date: Fri, 08 May 2015 13:43:42 +0000

branch: master
commit ee76efd979a5ff669394bb585b4854cb374dddf4
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Fix rounding error
    
    * avy.el (avy-subdiv): (log 14 14) is 1.0, but the floor of it can be
      either 1 or 0 due to machine precision. Add an eps to fix it.
    
    Fixes #37
---
 avy.el |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/avy.el b/avy.el
index 2f7d086..c5baaaf 100644
--- a/avy.el
+++ b/avy.el
@@ -29,6 +29,7 @@
 ;; in the original order by traversing the tree depth-first.
 
 ;;; Code:
+(require 'cl-macs)
 
 (defmacro avy-multipop (lst n)
   "Remove LST's first N elements and return them."
@@ -64,7 +65,7 @@ KEYS are placed appropriately on internal nodes."
 
 (defun avy-subdiv (n b)
   "Distribute N in B terms in a balanced way."
-  (let* ((p (1- (floor (log n b))))
+  (let* ((p (1- (floor (+ (log n b) 1e-6))))
          (x1 (expt b p))
          (x2 (* b x1))
          (delta (- n x2))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]