From: "Mattias Engdegård" <mattiase@acm.org>
To: 42597@debbugs.gnu.org
Subject: bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled
Date: Wed, 29 Jul 2020 14:07:32 +0200 [thread overview]
Message-ID: <1A998EAD-92A5-42FD-B382-33C0FE2A7D20@acm.org> (raw)
Unary +, *, min and max, all of which should be identity for numbers, convert -0.0 to +0.0 when byte-compiled:
(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!
next reply other threads:[~2020-07-29 12:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-29 12:07 Mattias Engdegård [this message]
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
[not found] <20200729133532.21725.qmail@mail.muc.de>
2020-08-03 15:36 ` bug#42597: 27.1; (+ -0.0) returns +0.0 when compiled Mattias Engdegård
2020-08-07 8:50 ` Mattias Engdegård
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1A998EAD-92A5-42FD-B382-33C0FE2A7D20@acm.org \
--to=mattiase@acm.org \
--cc=42597@debbugs.gnu.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.