emacs-diffs
[Top][All Lists]
Advanced

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

master 5757b6b: Calc: mend math-nth-root-float (bug#51209)


From: Mattias Engdegård
Subject: master 5757b6b: Calc: mend math-nth-root-float (bug#51209)
Date: Fri, 15 Oct 2021 06:34:53 -0400 (EDT)

branch: master
commit 5757b6b20422096de3f4c34e06e8c3b6252d6d85
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Calc: mend math-nth-root-float (bug#51209)
    
    Reported by Iñaki Cornejo.
    
    * lisp/calc/calc-math.el (math-nth-root-float):
    Fix old refactoring mistake.
    * test/lisp/calc/calc-tests.el (calc-nth-root): New test.
---
 lisp/calc/calc-math.el       | 5 +++--
 test/lisp/calc/calc-tests.el | 6 ++++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el
index 1c2e7bc..ba2b6b2 100644
--- a/lisp/calc/calc-math.el
+++ b/lisp/calc/calc-math.el
@@ -618,8 +618,9 @@ If this can't be done, return NIL."
 (defun math-nth-root-float (a nrf-n &optional guess)
   (math-inexact-result)
   (math-with-extra-prec 1
-    (let ((math-nrf-nf (math-float nrf-n))
-         (math-nrf-nfm1 (math-float (1- nrf-n))))
+    (let ((math-nrf-n nrf-n)
+         (math-nrf-nf (math-float nrf-n))
+          (math-nrf-nfm1 (math-float (1- nrf-n))))
       (math-nth-root-float-iter a (or guess
                                      (math-make-float
                                       1 (/ (+ (math-numdigs (nth 1 a))
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el
index 8a78a06..3eb6b34 100644
--- a/test/lisp/calc/calc-tests.el
+++ b/test/lisp/calc/calc-tests.el
@@ -810,6 +810,12 @@ An existing calc stack is reused, otherwise a new one is 
created."
   (should (equal (calcFunc-test6 3) (* (* 3 2) (- 3 1))))
   (should (equal (calcFunc-test7 3) (* 3 2))))
 
+(ert-deftest calc-nth-root ()
+  ;; bug#51209
+  (let* ((calc-display-working-message nil)
+         (x (calc-tests--calc-to-number (math-pow 8 '(frac 1 6)))))
+    (should (< (abs (- x (sqrt 2.0))) 1.0e-10))))
+
 (provide 'calc-tests)
 ;;; calc-tests.el ends here
 



reply via email to

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