emacs-devel
[Top][All Lists]
Advanced

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

Re: Using the GNU GMP Library for Bignums in Emacs


From: Paul Eggert
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Thu, 3 May 2018 11:26:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 05/03/2018 10:49 AM, Eli Zaretskii wrote:
(format "%016x" (lognot 257)) => "3ffffffffffffefe"

but the 16-hex-digit string should be "fffffffffffffefe".
But a 16-hex-digit fffffffffffffefe is not a fixnum, right?

Exactly right. If we have bignums, this will be straightforward; it'll work like Common Lisp, Python, etc. and it'll be obvious what to do. The problems mentioned in this thread mainly come from the fact that Emacs does not have bignums now and that some code may depend on fixnum overflow wrapping around.

Here's another way to think about it. (format "%016x" (lognot 257)) is already nonportable, as it yields "000000003ffffefe" on 32-bit platforms and "3ffffffffffffefe" on 64-bit platforms. Once we add bignums, the same expression should yield "-000000000000102" on all platforms. Code intended to be portable between old and new regimes already needs to worry about nonportability in this area, and it shouldn't be hard to adjust (if it needs adjusting at all). Code intended to run only under the new regime will be able to safely assume the expression yields "-000000000000102" on all platforms, regardless of whether the underlying platform is 32- or 64- or some other number of bits, and in the long run this will reduce the number of portability issues in Elisp code.




reply via email to

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