comparison lisp/calc/calc-math.el @ 84993:3788dd19e020

(math-smallest-emacs-expt): Make the computation more robust.
author Jay Belanger <jay.p.belanger@gmail.com>
date Mon, 01 Oct 2007 02:53:29 +0000
parents 5d2017af3365
children 39018b7044de
comparison
equal deleted inserted replaced
84992:5a1966aded2d 84993:3788dd19e020
67 "The largest exponent which Calc will convert to an Emacs float.") 67 "The largest exponent which Calc will convert to an Emacs float.")
68 68
69 (defvar math-smallest-emacs-expt 69 (defvar math-smallest-emacs-expt
70 (let ((x -1)) 70 (let ((x -1))
71 (while (condition-case nil 71 (while (condition-case nil
72 (expt 10.0 x) 72 (> (expt 10.0 x) 0.0)
73 (error nil)) 73 (error nil))
74 (setq x (* 2 x))) 74 (setq x (* 2 x)))
75 (setq x (/ x 2)) 75 (setq x (/ x 2))
76 (while (condition-case nil 76 (while (condition-case nil
77 (expt 10.0 x) 77 (> (expt 10.0 x) 0.0)
78 (error nil)) 78 (error nil))
79 (setq x (1- x))) 79 (setq x (1- x)))
80 (+ x 2)) 80 (+ x 2))
81 "The smallest exponent which Calc will convert to an Emacs float.") 81 "The smallest exponent which Calc will convert to an Emacs float.")
82 82