Message77721
About the name:
Java's Bignum has a 'significantBits' method, which apparently returns
the position of the MSB (i.e., numbits - 1).
GMP has mpz_sizeinbase; mpz_sizeinbase(n, 2) is almost the same as
numbits, except that mpz_sizeinbase(0, 2) is 1, not 0.
Mathematica has BitLength. I quite like this.
Googling for 'ilog2' returns a good few relevant hits; again, this is
really numbits - 1, not numbits.
How about n.bitlength? |
|
Date |
User |
Action |
Args |
2008-12-13 09:27:12 | mark.dickinson | set | recipients:
+ mark.dickinson, loewis, rhettinger, terry.reedy, vstinner, fredrikj |
2008-12-13 09:27:12 | mark.dickinson | set | messageid: <1229160432.18.0.983141755998.issue3439@psf.upfronthosting.co.za> |
2008-12-13 09:26:11 | mark.dickinson | link | issue3439 messages |
2008-12-13 09:26:11 | mark.dickinson | create | |
|