[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: calc: E command hangs Emacs.
From: |
Michaël Cadilhac |
Subject: |
Re: calc: E command hangs Emacs. |
Date: |
Fri, 21 Sep 2007 11:25:14 +0200 |
User-agent: |
Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) |
"yu jie" <address@hidden> writes:
>> (let ((x -1))
>> (while (condition-case nil
>> (message "1.Expt is %e" (expt 10.0 x))
>> (error nil))
>> (message "1.`x' is now %d" (setq x (* 2 x))))
>> (message "2.`x' is now %d" (setq x (/ x 2)))
>> (while (condition-case nil
>> (message "3.Expt is %e" (expt 10.0 x))
>> (error nil))
>> (message "3.`x' is now %d" (setq x (1- x))))
>> (+ x 2))
> *Message*:
> 1.Expt is 1.000000e+000
> 1.`x' is now 0
> 1.Expt is 1.000000e+000
> 1.`x' is now 0
> 1.Expt is 1.000000e+000
> 1.`x' is now 0
> 1.Expt is 1.000000e+000
> Loading debug...done
> Entering debugger...
Thanks a lot. As I read the pow(3) man page, the fact that it triggers
a ERANGE error is not documented, so it doesn't seem standard.
IMO, we should check by hand if an (under|over)flow is triggered.
Can you please try the following patch?
--- floatfns.c 26 Jul 2007 07:27:51 +0200 1.94
+++ floatfns.c 21 Sep 2007 11:22:16 +0200
@@ -454,7 +454,7 @@
(arg1, arg2)
register Lisp_Object arg1, arg2;
{
- double f1, f2;
+ double f1, f2, f3;
CHECK_NUMBER_OR_FLOAT (arg1);
CHECK_NUMBER_OR_FLOAT (arg2);
@@ -500,8 +500,11 @@
else if ((f1 == 0.0 && f2 < 0.0) || (f1 < 0 && f2 != floor(f2)))
domain_error2 ("expt", arg1, arg2);
#endif
- IN_FLOAT2 (f1 = pow (f1, f2), "expt", arg1, arg2);
- return make_float (f1);
+ IN_FLOAT2 (f3 = pow (f1, f2), "expt", arg1, arg2);
+ /* Check for overflow in the result. */
+ if (f1 != 0.0 && f3 == 0.0)
+ range_error ("expt", arg1);
+ return make_float (f3);
}
DEFUN ("log", Flog, Slog, 1, 2, 0,
Thanks again.
--
| Michaël `Micha' Cadilhac | Would someone please DTRT with this, |
| http://michael.cadilhac.name | then ACK? |
| JID/MSN: | -- Richard Stallman |
`---- address@hidden | - --'
pgp2uNVQf1qez.pgp
Description: PGP signature
- Re: calc: E command hangs Emacs.,
Michaël Cadilhac <=
- Message not available
- Message not available