GNU bug report logs -
#32252
[PATCH] %o and %x now format signed numbers
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Mon, 23 Jul 2018 19:14:02 UTC
Severity: normal
Tags: patch
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #59 received at 32252 <at> debbugs.gnu.org (full text, mbox):
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.
> #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 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.
No other approach has been proposed that would make much sense (that is, be
portable, be easily extendible to bignums, that sort of thing).
> 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.
This bug report was last modified 2 years and 323 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.