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

From: Paul Eggert <[email-masked]>
Date: Thu, 26 Jul 2018 00:59:56 -0700

Helmut Eller wrote:

> What's more interesting:
> (format "%x" (lognot 8)) => "-9"
> or
> (format "%x" (lognot 8)) => "3ffffffffffffff7"
> 
> For me, the first version is totally useless.

Shrug. It's what Common Lisp and Scheme do, and it works pretty well once you 
get used to it. Programs that need negative integers displayed modulo some power 
of 2 can use the mod or logand functions; that's the mathematically right way to 
do it anyway, and it's machine-independent.

> Of course there have been proposals: Do your bignum stuff with a
> different format specifier.

And prohibit %x on bignums? That would make little sense. Common Lisp and Scheme 
don't have any such prohibition; why should Emacs Lisp? Again, programs that 
need just the low-order bits of a negative integer can use 'mod' or a mask.

> Here is another proposal: Add a read syntax for unsigned fixnums like
> #x3fffffffffffffffu or alternatively #xu3fffffffffffffff.

That's heading down the wrong path. Emacs Lisp does not have unsigned fixnums, 
so why add a syntax for a data type that does not exist? And Emacs Lisp should 
not add such a data type, as it is a low-level machine concept unsuitable for 
Lisp, is not needed in Emacs Lisp, and would cause unnecessary complexity in 
documentation and implementation.