find position of most significant bit ?

George Coulouris coulouri@ncbi.nlm.nih.gov
Tue, 26 Nov 2002 10:41:30 -0500


Hello,

Is there an efficient way to compute the position of the most 
significant bit in a multiprecision integer? Basically, like 
mpz_scan1(), but instead of scanning from LSB to MSB, the other way around.

mpz_sizeinbase(op, 2) would do it, but I don't know if there is a more 
efficent way to accomplish this.

Regards,
George Coulouris