[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Paul Eggert
Subject: bug#32252: [PATCH] %o and %x now format signed numbers
Date: Thu, 26 Jul 2018 00:59:56 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Helmut Eller wrote:

What's more interesting:
(format "%x" (lognot 8)) => "-9"
(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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]