emacs-devel
[Top][All Lists]
Advanced

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

Re: integer overflow handling for most-negative-fixnum


From: Andy Moreton
Subject: Re: integer overflow handling for most-negative-fixnum
Date: Mon, 23 Jul 2018 12:49:28 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt)

On Sat 21 Jul 2018, Paul Eggert wrote:

> Andy Moreton wrote:
>
>> Bignums are not relevant to this discussion.
>
> I'm afraid they are. Whatever solution we come up with in this problem, should
> be compatible with bignums. Our solution should not assume that integers are
> of fixed width.
>
>> Non base10 representations
>> of emacs fixnums are not treated consistently, and prevent round trip
>> handling of the full range of valid fixnum values.
>
> As Helmut mentioned, read and print work just fine. The problem is that if you
> use some formats, you don't get a round trip. Of course this problem is
> endemic to formats; e.g., (read (format "%g" X)) does not yield X for all
> floating-point values X, due to rounding. Still, it would be helpful if the
> usual kind of formatting hex integers were round-trip more often. I'll propose
> something along these lines in my next email.

I see that you have pushed 57c4bc146b ("0x%x → %#x in elisp formats"),
which will cause breakage as format is not well behaved:

ELISP> (format "%#x" 1)
"0x1"
ELISP> (format "%#x" 0)
"0"                      ; Missing "0x" prefix (same misfeature as in C)

ELISP> (format "%#08x" 1)
"0x000001"               ; Wrong number of digits printed
ELISP> (format "%#08x" 0)
"00000000"

For both of the above reasons, this change is not a good idea.

    AndyM




reply via email to

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