Re: how to get the thighest bit position in big integers?

2008-10-10 Thread mmgarvey
On Oct 8, 10:56 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: >> I think that (0).numbits()==-1 is the natural solution. > > Can you clarify this?  Why is -1 the natural solution? I > can see a case for 0, for -infinity (whatever that means), > or for raising an exception, but I can't see why -1 wo

Re: how to get the thighest bit position in big integers?

2008-10-07 Thread mmgarvey
> See also http://bugs.python.org/issue3439 > where there's a proposal to expose the _PyLong_NumBits method.  This > would give an O(1) solution. > > In every case I can think of, I've wanted (0).numbits() to be 0. Here is surely the wrong place to respond to http://bugs.python.org/msg71384 but

how to get the thighest bit position in big integers?

2008-10-05 Thread mmgarvey
Hi, I'm using python to develop some proof-of-concept code for a cryptographic application. My code makes extended use of python's native bignum capabilities. In many cryptographic applications there is the need for a function 'get_highest_bit_num' that returns the position number of the highest