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 forgotten about to
Stan Cook wrote:
Is there a function I've forgotten about to convert an
integer to a string?
str(value)
/F
--
http://mail.python.org/mailman/listinfo/python-list
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. Is there a function I've
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 %s int, but that
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 int, but that
doesn't work. Is there a
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
string. I tried to set a variable = to %s
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.0
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. Is there a function I've
Felipe Almeida Lessa wrote:
Hmmm, you're right.
math.floor(math.log(x, 10)) + 1
x = 0
/F
--
http://mail.python.org/mailman/listinfo/python-list
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:
10 matches
Mail list logo