On Sat, 19 Sep 2009 at 10:25AM -0400, David Joyner wrote:
> Do you mean this?
> 
> sage: n = 1234567890123456789
> sage: len(str(n))
> 19

There's also n.ndigits(), which I think directly returns the number of
digits without doing any conversion to a string. You can even specify
different bases, so if n = 8, you get 1 for base 10, and 3 for base 2.
You can also put in really large bases: 

sage: n = 1025
sage: n.ndigits(1024)
2


Dan

-- 
---  Dan Drake
-----  http://mathsci.kaist.ac.kr/~drake
-------

Attachment: signature.asc
Description: Digital signature

Reply via email to