Em Dom, 2006-06-11 às 22:33 +0200, Sybren Stuvel escreveu: > Felipe Almeida Lessa enlightened us with: > > To see how many decimal digits it has: > > > > import math > > math.ceil(math.log(i, 10)) > > That doesn't work properly. > > >>> import math > >>> math.ceil(math.log(10000, 10)) > 4.0 > >>> math.ceil(math.log(10001, 10)) > 5.0 > > But "10000" certainly has as much digits as "10001".
Hmmm, you're right. math.floor(math.log(x, 10)) + 1 -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list