Message77721
| Author |
mark.dickinson |
| Recipients |
fredrikj, loewis, mark.dickinson, rhettinger, terry.reedy, vstinner |
| Date |
2008年12月13日.09:26:11 |
| SpamBayes Score |
0.0005085584 |
| Marked as misclassified |
No |
| Message-id |
<1229160432.18.0.983141755998.issue3439@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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? |
|