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: Sun, 22 Apr 2018 02:06:11 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

Siraphob (Ben) Phipathananunth wrote:
Would it not slow down computation to have to constantly convert
between the two types?

A bit perhaps, but it shouldn't be that big a deal. Most integer computation will likely be fixnum only, and the only slowdown there will be integer overflow checking that we currently aren't doing. With decent hardware and compiler, I'd guess this would cost us three machine instructions per Lisp arithmetic operation, including the conditional branch that is typically not taken. Hardly anybody will notice.
In such a case, a fix could
be to convert lisp numbers exceeding fixnum limits to bignums for the
rest of the number's life (until GC). This ensures memory usage is kept
low for fixnum computations.

Yes, the idea is to use bignums to represent numbers outside of fixnum range, and to use fixnums to represent numbers inside fixnum range. Bignums require garbage collection; fixnums do not.



reply via email to

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