mpz_tstbit is limited ?

Christian P. MOMON
Thu, 26 Dec 2002 03:10:34 +0100

delta trinity wrote:
>>  Hi,
>> The definition of the mpz_tstbit function is:
>> int mpz_tstbit (mpz_t op, unsigned long int bit_index)
>>  Why not:
>> bool mpz_tstbit (mpz_t op, unsigned long int bit_index)
> Because bool is a c++ specific keyword and gmp is built to be used with 
> standatd 'c'.  Standard 'c' doesn't know about 'bool'.

Yes. I imagine that the futur C++ interface method will return bool 8->

>>  Why not:
>> int mpz_tstbit (mpz_t op, mpz_t bit_index)
> Because it wouldn't make much sence to test bits larger than a long 
> int.  This would be a test un a number that is 4 bilion bits wide.  So, 
> for speed concert, we use a unsigned long.

Hmmmmm ... 22^32 is really a wide number and probability to need it is 
really poor and i understand the speed concert.

  But imagine we use mpz_t as a set of bits (or a bit string), so
the max size of the set is 4,294,967,296 bits, so only 512Mo.

Today, is it enough ????? GMP is very interesting to put index in mpz_t
for big bit string.

Two solutions:
a) create a other new function which test if the index of bit is less
than 232 (fast test ?) and so call the actual function and do other if not.
b) wait for 64 bits processor and use long long (or quad) block.

In case of a), what would be the test ? Is it a fast one ?

What do you think about this ?


        __    __    __
  (o_  |     |__|  |  |         "CPM est Christian P. M____."    ('<
  /)   |__ . |   . |  | .        ,',)