[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 09:55:53 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

On 07/26/2018 02:56 AM, Helmut Eller wrote:
How often does one need to print a
time value in hex notation?

It happens every time I run Emacs, in standard code shipped with Emacs. I discovered this while doing compatibility checking before I proposed this change. (The code in question continues to work just fine when binary-as-unsigned is nil.)

format-time-string doesn't even support that.

We're talking about 'format' not 'format-time-string', and Emacs code does apply 'format' with %x to the tricky little integers that 'current-time' returns. It's a real hassle, and this hassle is pervasive in Emacs. Having bignums would simplify it significantly.

And this problem is not limited to times. It's also file sizes, buffer and string sizes (currently limited to fixnums, but they shouldn't be), glyph codes, inode numbers, device numbers, file descriptor numbers, inotify masks, windowing parameters, and other stuff I don't even know about. It's pervasive and is a real hassle.

By the way, the format %x compatibility checking I mentioned is partly why I have confidence that the practical effects of this change will be minor. Many of the problems that I thought might happen, don't in fact happen, because people who attempt to format negative numbers with %x have already run into portability hassles on 32- vs 64-bit platforms, and so they have written their code so that the platform choice doesn't matter, either by ensuring that the integer is nonnegative or by not caring what string is generated so long as it doesn't lose information. Code written like this (and so far, that's all the code I've found) works just fine when 'format'  %x works like it does in Common Lisp or Scheme.

reply via email to

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