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 #106 received at 32252 <at> debbugs.gnu.org (full text, mbox):
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.
This bug report was last modified 2 years and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.