In article <[EMAIL PROTECTED]>,
Felipe Almeida Lessa  <[EMAIL PROTECTED]> wrote:
                        .
                        .
                        .
>math.floor(math.log(x, 10)) + 1
>
>-- 
>Felipe.
>

... and you're restricting to the positive integers, I take it?
I still have rounding problems:
  >>> def l(x):
  ...     return math.floor(math.log(x, 10)) + 1
  ... 
  >>> l(10)
  2.0
  >>> l(100)
  3.0
  >>> l(1000)
  3.0
  >>> l(10000)
  5.0
  >>> l(100000)
  6.0
  >>> l(1000000)
  6.0
  >>> l(10000000)
  8.0

While modest mollification improves these results, it's going
to be tough to beat len(str(x)).
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to