On Feb 3, 1:19 am, Mark Wooding <m...@distorted.org.uk> wrote: > Yeah, I made some arbitrary choices about what to do with non-positive > inputs. If you prefer other answers, use 'em. My ones work well with > signed-magnitude representations where the sign is stored separately.
Not *that* arbitrary: they're the same choices that were made (after some discussion) for the int.bit_length method, which is what the OP was looking to replace. They're also identical to the choices that Mathematica made for its BitLength function... As Mark says, this seems a natural choice for sign-magnitude representation, which is what almost every bignum library seems to use under the hood. Mark -- http://mail.python.org/mailman/listinfo/python-list