unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Brinkhoff <lars@nocrew.org>
Subject: Re: Strange division using mixed integers and floats
Date: 28 Apr 2004 15:20:56 +0200	[thread overview]
Message-ID: <85smeodyrr.fsf@junk.nocrew.org> (raw)
In-Reply-To: x5brlcz7k4.fsf@lola.goethe.zz

David Kastrup <dak@gnu.org> writes:
> Richard Stallman <rms@gnu.org> writes:
> >     But this behaviour is *highly* confusing:
> >     (/ 5 4 2.3) => 0.4347826086956522
> >     Cf. (/ 5 4.0 2.3) => 0.5434782608695653
> > 
> > We could change the functions to convert the arguments to floating
> > point at the start if any is floating point.  Is there any reason
> > not to do that?
> 
> Efficiency?  Lisp is not a statically typed language.  We don't know
> the type of the arguments until after they have been evaluated.  We
> would have to store all intermediate results away before being
> allowed to do the first operation.

Seems like it's only a matter of changing arith_driver to do

      if (FLOATP (val))
        {
          if (code == Adiv)
            return float_arith_driver (0.0, 0, code, nargs, args);
          else
            return float_arith_driver ((double) accum, argnum, code,
                                       nargs, args);
        }

or similar.  Loss of efficiency should be small.

> Also (/ 5 4 2.3) would no longer be equivalent to (/ (/ 5 4) 2.3).

That's more significant, as it's a user-visible change.

-- 
Lars Brinkhoff,         Services for Unix, Linux, GCC, HTTP
Brinkhoff Consulting    http://www.brinkhoff.se/

  reply	other threads:[~2004-04-28 13:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <yoijk702ye7i.fsf@frealaf.dd.chalmers.se>
2004-04-28 10:13 ` Strange division using mixed integers and floats Richard Stallman
2004-04-28 11:05   ` David Kastrup
2004-04-28 13:20     ` Lars Brinkhoff [this message]
2004-04-28 14:02     ` Andreas Schwab
2004-04-28 15:59       ` Kevin Rodgers
2004-04-29 13:31     ` Richard Stallman
2004-04-29 17:17       ` peta

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=85smeodyrr.fsf@junk.nocrew.org \
    --to=lars@nocrew.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).