From: Helmut Eller <eller.helmut@gmail.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 32252@debbugs.gnu.org
Subject: bug#32252: [PATCH] %o and %x now format signed numbers
Date: Wed, 25 Jul 2018 08:58:25 +0200 [thread overview]
Message-ID: <m21sbr3ipa.fsf@gmail.com> (raw)
In-Reply-To: <6f720005-b5e4-5d1c-b4e8-a8992c7635c4@cs.ucla.edu> (Paul Eggert's message of "Tue, 24 Jul 2018 17:50:46 -0700")
On Tue, Jul 24 2018, Paul Eggert wrote:
> Helmut Eller wrote:
>
>> In practice, printf ("%x", (int)N) prints the bits in N as unsigned
>> integer not as signed integer.
>
> That's two operations not one, and even there the results disagree
> with what (format "%x" N) does. On every Emacs platform I've ever used
> the C output begins with a different hex digit than the Emacs Lisp
> output. Emacs has never done %x just like that unportable C code, and
> likely will never do so.
Nobody is arguing for printing the tag-bits. And what Emacs has done is
fairly obvious to everybody.
>> #x-1 maybe interesting to the read function but it's not interesting to
>> humans. Humans want to see #x3fffffffffffffff.
>
> I doubt very much that most humans really want to see an error-prone
> notation like that (can you easily spot the difference between it and
> #x3ffffffffffffffff? I can't). And even if some humans did want it,
> they won't get it on 32-bit Emacs. This whole idea is a bad approach
> for Emacs.
What's more interesting:
(format "%x" (lognot 8)) => "-9"
or
(format "%x" (lognot 8)) => "3ffffffffffffff7"
For me, the first version is totally useless.
> What I expect most users would prefer is an approach where 'read' and
> 'format' are inverses, e.g., (read (printf "#x%x" N)) returns N for
> every integer N. Emacs doesn't do that now, and the proposed patch
> fixes things so that it does.
The inverse of read is print, not format or printf.
> No other approach has been proposed that
> would make much sense (that is, be portable, be easily extendible to
> bignums, that sort of thing).
Of course there have been proposals: Do your bignum stuff with a
different format specifier.
Here is another proposal: Add a read syntax for unsigned fixnums like
#x3fffffffffffffffu or alternatively #xu3fffffffffffffff.
>> you should have no problem with introducing an
>> new specifier for this.
>
> I'd rather not, as the hex stuff has never worked right in Emacs and
> we shouldn't be codifying old bugs.
It was already codified in the documentation, even the much more dubios
flonum case. It's really annoying when documented behavior changes.
Helmut
next prev parent reply other threads:[~2018-07-25 6:58 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 19:12 bug#32252: [PATCH] %o and %x now format signed numbers Paul Eggert
2018-07-23 19:48 ` Helmut Eller
2018-07-23 19:49 ` Drew Adams
2018-07-23 23:30 ` Paul Eggert
2018-07-24 1:20 ` Drew Adams
2018-07-24 2:04 ` Paul Eggert
2018-07-24 2:38 ` Eli Zaretskii
2018-07-24 2:44 ` Paul Eggert
2018-07-24 14:29 ` Eli Zaretskii
2018-07-24 4:15 ` Drew Adams
2018-07-23 23:39 ` Paul Eggert
2018-07-24 1:16 ` Drew Adams
2018-07-25 3:53 ` Richard Stallman
2018-07-25 21:56 ` Drew Adams
2018-07-27 3:20 ` Richard Stallman
2018-07-24 4:49 ` Helmut Eller
2018-07-24 14:22 ` Paul Eggert
2018-07-24 14:35 ` Andreas Schwab
2018-07-24 18:15 ` Helmut Eller
2018-07-25 0:50 ` Paul Eggert
2018-07-25 2:41 ` Eli Zaretskii
2018-07-25 17:21 ` Paul Eggert
2018-07-25 17:28 ` Eli Zaretskii
2018-07-26 7:44 ` Paul Eggert
2018-07-26 8:04 ` Helmut Eller
2018-07-26 8:16 ` Paul Eggert
2018-07-25 6:58 ` Helmut Eller [this message]
2018-07-26 7:59 ` Paul Eggert
2018-07-26 8:43 ` Helmut Eller
2018-07-26 9:15 ` Paul Eggert
2018-07-26 9:39 ` Helmut Eller
2018-07-26 9:31 ` Andreas Schwab
2018-07-26 9:40 ` Robert Pluim
2018-07-26 9:56 ` Helmut Eller
2018-07-26 16:55 ` Paul Eggert
2018-07-26 17:16 ` Helmut Eller
2018-07-26 17:50 ` Paul Eggert
2018-07-26 18:35 ` Helmut Eller
2018-07-26 21:07 ` Paul Eggert
2018-07-24 18:27 ` Eli Zaretskii
2018-07-25 0:54 ` Paul Eggert
2018-07-25 8:09 ` Andreas Schwab
2018-07-25 20:16 ` Paul Eggert
2018-07-25 14:17 ` Eli Zaretskii
2018-07-25 23:33 ` Brett Gilio
2018-07-26 7:26 ` Paul Eggert
2018-07-24 16:26 ` Andy Moreton
2018-07-25 10:08 ` Andy Moreton
2018-07-26 12:52 ` Andy Moreton
2018-07-26 12:54 ` Andy Moreton
2018-07-26 17:18 ` Helmut Eller
2018-08-23 9:37 ` Helmut Eller
2022-07-04 1:03 ` bug#32252: i find binary-as-unsigned to be very helpful snickerbockers
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=m21sbr3ipa.fsf@gmail.com \
--to=eller.helmut@gmail.com \
--cc=32252@debbugs.gnu.org \
--cc=eggert@cs.ucla.edu \
/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).