Re: how to get the length of a number

2006-06-11 Thread Cameron Laird
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 pr

Re: how to get the length of a number

2006-06-11 Thread Fredrik Lundh
Felipe Almeida Lessa wrote: > Hmmm, you're right. > > math.floor(math.log(x, 10)) + 1 x = 0 -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get the length of a number

2006-06-11 Thread Claudio Grondi
Stan Cook wrote: > Can anyone tell me how to get the length of a number. I know > len(string) will get the length of a string, but it doesn't like > len(int). I seem to remember something like %s string. I tried to set > a variable = to %s int, but that doesn't work

Re: how to get the length of a number

2006-06-11 Thread Felipe Almeida Lessa
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(1, 10)) > 4

Re: how to get the length of a number

2006-06-11 Thread Felipe Almeida Lessa
Em Dom, 2006-06-11 às 13:17 -0700, Saketh escreveu: > Stan Cook wrote: > > Can anyone tell me how to get the length of a number. I > > know len(string) will get the length of a string, but it > > doesn't like len(int). I seem to remember something like %s > > st

Re: how to get the length of a number

2006-06-11 Thread Stan Cook
Saketh wrote: > Stan Cook wrote: >> Can anyone tell me how to get the length of a number. I >> know len(string) will get the length of a string, but it >> doesn't like len(int). I seem to remember something like %s >> string. I tried to set a variable = to %s in

Re: how to get the length of a number

2006-06-11 Thread Felipe Almeida Lessa
Em Dom, 2006-06-11 às 20:10 +, Stan Cook escreveu: > Can anyone tell me how to get the length of a number. I > know len(string) will get the length of a string, but it > doesn't like len(int). I seem to remember something like %s > string. I tried to set a variable = to

Re: how to get the length of a number

2006-06-11 Thread Saketh
Stan Cook wrote: > Can anyone tell me how to get the length of a number. I > know len(string) will get the length of a string, but it > doesn't like len(int). I seem to remember something like %s > string. I tried to set a variable = to %s int, but that > doesn't w

Re: how to get the length of a number

2006-06-11 Thread Fredrik Lundh
Stan Cook wrote: > Is there a function I've forgotten about to convert an > integer to a string? str(value) -- http://mail.python.org/mailman/listinfo/python-list

how to get the length of a number

2006-06-11 Thread Stan Cook
Can anyone tell me how to get the length of a number. I know len(string) will get the length of a string, but it doesn't like len(int). I seem to remember something like %s string. I tried to set a variable = to %s int, but that doesn't work. Is there a function I've for