GNU bug report logs - #64441
29.0.92; elisp arithmetic error at ielm prompt

Previous Next

Package: emacs;

Reported by: Van Ly <van.ly <at> sdf.org>

Date: Mon, 3 Jul 2023 16:26:02 UTC

Severity: normal

Tags: notabug

Found in version 29.0.92

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: Van Ly via "Bug reports for GNU Emacs, the Swiss army knife of text
 editors" <bug-gnu-emacs <at> gnu.org>
Cc: Van Ly <van.ly <at> sdf.org>, 64441 <at> debbugs.gnu.org
Subject: Re: bug#64441: 29.0.92; elisp arithmetic error at ielm prompt
Date: Mon, 03 Jul 2023 18:50:58 +0200
On Mon, 3 Jul 2023 16:20:34 GMT Van Ly via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> wrote:

> Hello,
>
> The following calculation errors in elisp.
>
>   ELISP> (/ (* (/ 3 4) (/ 7 13)) (/ 5 12))
>   *** Eval error ***  Arithmetic error
>
> The SBCL repl doesn't.
>
>   CL-USER> (/ (* (/ 3 4) (/ 7 13)) (/ 5 12))
>   63/65 (0.9692308, 1260/13%)
>
> Steps to reproduce the error.
>
>   1. start using, 'emacs -Q'
>   2. get to the ielm elisp prompt, 'M-x ielm'
>   3. enter the above calculation

`/' in Elisp is different from `/' in Common Lisp.

(elisp) Arithmetic Operations:

  If all the arguments are integers, the result is an integer,
  obtained by rounding the quotient towards zero after each division.

Hence (/ 3 4), (/ 7 13) and (/ 5 12) all evaluate to 0, and "If you
divide an integer by the integer 0, Emacs signals an ‘arith-error’
error".

But in Common Lisp
(http://www.lispworks.com/documentation/HyperSpec/Body/f_sl.htm):

  If each argument is either an integer or a ratio, and the result is
  not an integer, then it is a ratio.

Hence (/ 3 4) => 3/4,  (/ 7 13) => 7/13 and (/ 5 12) => 5/12

Steve Berman




This bug report was last modified 1 year and 258 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.