From: michael@cadilhac.name (Michaël Cadilhac)
To: "yu jie" <yujie052@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: calc: E command hangs Emacs.
Date: Fri, 21 Sep 2007 11:25:14 +0200 [thread overview]
Message-ID: <87zlzgl69x.fsf@cadilhac.name> (raw)
In-Reply-To: <42b562540709201741s28d34896h9c6a69b8db676794@mail.gmail.com> (yu jie's message of "Fri, 21 Sep 2007 08:41:48 +0800")
[-- Attachment #1.1.1: Type: text/plain, Size: 885 bytes --]
"yu jie" <yujie052@gmail.com> 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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: floatfns.patch --]
[-- Type: text/x-patch, Size: 753 bytes --]
--- 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,
[-- Attachment #1.1.3: Type: text/plain, Size: 344 bytes --]
Thanks again.
--
| Michaël `Micha' Cadilhac | Would someone please DTRT with this, |
| http://michael.cadilhac.name | then ACK? |
| JID/MSN: | -- Richard Stallman |
`---- michael.cadilhac@gmail.com | - --'
[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]
[-- Attachment #2: Type: text/plain, Size: 142 bytes --]
_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel
next parent reply other threads:[~2007-09-21 9:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <42b562540709171814v3257a1adic5202f42911aad37@mail.gmail.com>
[not found] ` <873axcrrcv.fsf@cadilhac.name>
[not found] ` <42b562540709181923t54c3876of89a0c3322b459cc@mail.gmail.com>
[not found] ` <876426n1hu.fsf@cadilhac.name>
[not found] ` <42b562540709191805tdbc3da4xf0f8d0cc2456cada@mail.gmail.com>
[not found] ` <876425n5gg.fsf@cadilhac.name>
[not found] ` <42b562540709201741s28d34896h9c6a69b8db676794@mail.gmail.com>
2007-09-21 9:25 ` Michaël Cadilhac [this message]
[not found] ` <E1IYgkh-000069-ME@fencepost.gnu.org>
2007-09-21 11:49 ` Possible bug in `expt'. (was: calc: E command hangs Emacs.) Michaël Cadilhac
[not found] ` <42b562540709232026s650e98ebgbeb780881565c0fa@mail.gmail.com>
2007-09-24 6:49 ` calc: E command hangs Emacs Michaël Cadilhac
2007-10-01 9:17 ` Michaël Cadilhac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zlzgl69x.fsf@cadilhac.name \
--to=michael@cadilhac.name \
--cc=emacs-devel@gnu.org \
--cc=yujie052@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).