|
From: | Paul Eggert |
Subject: | bug#32252: [PATCH] %o and %x now format signed numbers |
Date: | Tue, 24 Jul 2018 17:50:46 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
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.
[Prev in Thread] | Current Thread | [Next in Thread] |