Number of limbs for an unsigned long

Marc Glisse marc.glisse at inria.fr
Tue Mar 15 16:15:16 CET 2011


Hello,

what is the best way to check how many limbs are necessary to be able to 
store any unsigned long?

mpz_set_si has the simplest test of all: two limbs if there are nails, 1 
otherwise. Is that safe/wasteful?

The current macro in gmpxx.h uses sizeof(long) so I can't use it in #if 
MACRO > 1, and gmp-impl.h uses SIZEOF_UNSIGNED_LONG from config.h so I 
can't use it in gmpxx.h.

-- 
Marc Glisse


More information about the gmp-devel mailing list