[sage-edu] Re: integer, tostring, length?

2009-09-19 Thread Dan Drake
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

[sage-edu] Re: integer, tostring, length?

2009-09-19 Thread calcpage
Yes, that was it! Thank you! How easy it is to forget syntax in one environment when using another. I was teaching java all day yesterday and I just couldn't remember the equivalent in Sage! BTW, I had worksheets in sagenb online where I saved a lot of 'notes to self' whenever I figured out

[sage-edu] Re: integer, tostring, length?

2009-09-19 Thread David Joyner
Do you mean this? sage: n = 1234567890123456789 sage: len(str(n)) 19 On Sat, Sep 19, 2009 at 10:14 AM, wrote: > > Sorry, silly question: > > OK, I know I've done this in Sage before, but I can't remember for the > life of me how. > > I'm writing a program that computes large integers and test

[sage-edu] integer, tostring, length?

2009-09-19 Thread calcpage
Sorry, silly question: OK, I know I've done this in Sage before, but I can't remember for the life of me how. I'm writing a program that computes large integers and tests for primality. What I'd like to do is print out the integer and how many digits it has. I seem to remember having to con