unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: 64441@debbugs.gnu.org
Cc: van.ly@sdf.org
Subject: bug#64441: 29.0.92; elisp arithmetic error at ielm prompt
Date: Mon, 03 Jul 2023 18:50:58 +0200	[thread overview]
Message-ID: <878rbx547h.fsf@gmx.net> (raw)
In-Reply-To: <202307031620.363GKYEA003729@sdf.org> (Van Ly via's message of "Mon, 3 Jul 2023 16:20:34 GMT")

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@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





  reply	other threads:[~2023-07-03 16:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 16:20 bug#64441: 29.0.92; elisp arithmetic error at ielm prompt Van Ly via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-03 16:50 ` Stephen Berman [this message]
2023-07-04 10:44   ` Van Ly via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-03 16:53 ` Eli Zaretskii
2023-09-08 16:20   ` Stefan Kangas

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=878rbx547h.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=64441@debbugs.gnu.org \
    --cc=van.ly@sdf.org \
    /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).