GMP with small numbers
Paulo J. Matos
pocmatos at gmail.com
Sat Jun 17 23:44:43 CEST 2006
Does GMP use internal long int type and long int operations on small
numbers and allocates internally special object for big num if one is
needed or uses bignums even if you are computing "1+1" a lot of times?
The problem is: an application requires big nums rarely in its
lifetime, still they are crucial when needed. I can manage to use GMP
all the way but for efficiency I might think of implementing a new
number structure in C++ which uses long long ints (or the biggest type
provided by the compiler) and overload the arithmetic operators, then
check internally for overflows and if one is about to happen I just
switch the numbers internally for the GMP numbers and keep computing.
I can even switch back if I notice the numbers already fit in a
machine size number. Basically, GMP does this automatically or if I
want this kind of stuff for efficiency, I have to implement it myself?
Paulo Jorge Matos - pocm at sat inesc-id pt
Computer and Software Engineering
INESC-ID - SAT Group
More information about the gmp-discuss