Subject: bug#32252: [PATCH] %o and %x now format signed numbers

From: Paul Eggert <[email-masked]>
Date: Tue, 24 Jul 2018 07:22:52 -0700

Helmut Eller wrote:
> With your change %x will also have quite a different meaning in C11.

Not really, as Emacs (format "%x" N) agrees with C11 printf ("%x", N) in all 
values of N that are valid in both languages. In C11, negative values are not 
valid, as printf ("%x", N) has undefined behavior when N is negative. So we are 
discussing an area where Emacs Lisp can define behavior without introducing 
incompatibilities with C11.

If we changed (format "%x" -1) to signal an error instead, that would also be 
upward-compatible with C11. However, it's more useful for something like (format 
"#x%x" -1) to output a string that can 'read' can scan to get -1, something 
that's not true of Emacs now.

>> This seems like overkill for such a small
>> change to functionality that hardly ever matters; plus, %x, %X and %o
>> would continue to have problematic machine-dependent semantics and
>> would not be sensibly extensible to bignums.
> 
> If it doesn't matter to you then why make the change/break at all?

It does matter to me, actually. I think Emacs should have sensible behavior even 
in corner cases that hardly ever arise in real programs.