unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: 42597@debbugs.gnu.org
Subject: bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled (fwd)
Date: Wed, 29 Jul 2020 18:32:45 +0000	[thread overview]
Message-ID: <xjfwo2mcgtu.fsf@sdf.org> (raw)
In-Reply-To: <ff6ceb4e-27a0-9339-34ab-1a6ad40352c@muc.de> (Alan Mackenzie's message of "Wed, 29 Jul 2020 15:41:27 +0200 (CEST)")

Alan Mackenzie <acm@muc.de> writes:

> Hello, Mattias.
>
> In article <mailman.247.1596026464.2739.bug-gnu-emacs@gnu.org> you wrote:
>> Unary +, *, min and max, all of which should be identity for numbers,
>> convert -0.0 to +0.0 when byte-compiled:
>
> They convert what?
>
>> (defun f (x) (+ x))
>> (f -0.0)
>> => -0.0
>> (byte-compile 'f)
>> (f -0.0)
>> => 0.0
>
>> The reason is that byte-compile-associative transforms (+ x), (* x),
>> (min x) and (max x) into (+ x 0).
>
>> No patch yet (sorry!) but I'm not sure what would be the best way to go
>> about it. Some possibilities:
>
>> A. Use a full 1-argument call, like (+ x). This is more expensive
>>    (about 1.8×) since the general function call mechanism has to be used.
>> B. Use (* x 1) instead; this appears to work. This is also more
>>    expensive (1.6×); not sure why.
>> C. Add a new byte-op. Fast but probably overkill.
>
>> Better suggestions welcome!
>
> This is an example of what happens when ignorant people rule the roost.
> -0.0 and +0.0 are identically the same thing.  It should not take a
> degree in mathematics (which I have) to realise this.  When you put
> mathematical nonsense into <whatever thing is producing -0.0> you cannot
> help but get nonsense back out.
>
> 0.0 does not need two different names.  It can do nothing but produce
> confusion, what has clearly happened here at whatever level.
>
> So my suggestion D. would be: Eliminate "-0.0" from Emacs Lisp.  If this
> is not possible for whatever reason, then E. Do nothing.

For completeness I'd like to link what is prescribed on that for CL:

<http://clhs.lisp.se/Body/f_eq_sle.htm>

"
Notes:

= differs from eql in that (= 0.0 -0.0) is always true, because =
compares the mathematical values of its operands, whereas eql compares
the representational values, so to speak.
"

  Andrea

-- 
akrl@sdf.org





      reply	other threads:[~2020-07-29 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 12:07 bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled Mattias Engdegård
2020-07-29 13:41 ` bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled (fwd) Alan Mackenzie
2020-07-29 18:32   ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

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=xjfwo2mcgtu.fsf@sdf.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=42597@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=akrl@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).