[Top][All Lists]

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

Re: integer overflow handling for most-negative-fixnum

From: Paul Eggert
Subject: Re: integer overflow handling for most-negative-fixnum
Date: Sat, 21 Jul 2018 10:48:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Stefan Monnier wrote:
The only problem I see above is how to *print*
a value like #x-2000000000000000, which is currently done incorrectly.

Yes, this is the crux of the matter.

to me both
behaviors are valid and desirable, so we need some way for the
programmer to choose which one to use when

How about this idea. First, we extend 'format' to support bitwidth modifiers for twos-complement representation. For example, (format "%/24x" -1) would format just the low-order 24 bits of the integer, and would return "ffffff" regardless of machine word size or whether bignums are used.

Second, we change (format "%x" -1) to return "-1" rather than a machine-dependent string like "3fffffffffffffff" as it does now. That would make Elisp be more machine-independent, would solve Andy's problem, and would solve other problems once we have bignums, and in hindsight it's what we should have done originally. However, it would be an incompatible change, so let's have the behavior depend on a compatibility variable, much as we already do for read-integer-overflow-as-float.

reply via email to

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