On Wed, Apr 30, 2008 at 12:28 AM, Yann Le Du <[EMAIL PROTECTED]> wrote:
>
>  Hello,
>
>  First, the function oct does not work properly, it seems.
>
>  oct(2345) fails in Sage (but works in Python)
>  oct(int(2345)) works
>  hex(2345) works
>
>  Irc said it was the preparser. Why would the input of oct be preparsed
>  correctly and not that of hex ?

I think you asked this question backwards.  Anyway, the problem
is that nobody implemented __oct__ for Sage integers, but they
did implement __hex__.  Note that oct(...) calls __oct__:

sage: a = 2345
sage: a.__hex__()
'929'
sage: a.__oct__()
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/Users/was/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'sage.rings.integer.Integer'
object has no attribute '__oct__'

In the meantime you can do either

sage: oct(int(a))
'04451'

or

sage: a.digits(8)
[1, 5, 4, 4]

or

sage: a.str(base=8)
'4451'

I've opened a trac ticket so that __oct__ will get implemented soon
for the integers:

   http://trac.sagemath.org/sage_trac/ticket/3062

>  Sage uses notions from abstract algebra. I never use abstract algebra when
>  doing my coding in physics. I guess software like Mathematica kind of
>  guesses the best way to proceed with the input I give. Now, this guess
>  might not be the most appropriate.
>
>  So I'd be grateful if anyone had some suggestions for a book on abstract
>  algebra that would teach me the practical usage of rings, fields, etc.
>  from a computational point of view ; something like "common computational
>  errors and fallacies corrected by an abstract algebra approach", something
>  that would build upon ideas like "1/3 + 1/10**20 - 1/3" is better done in
>  the the rationals than in the floats. Maybe some book similar to Forman
>  Acton's books that would explicitly use notions of abstract algebra.
>
>  I had a look at Schaum's Modern Abstract Algebra by Ayres, 2004, but
>  comments on amazon mentioned multiple errors, opacities and out of
>  datedness. Irc suggested wikipedia. Any other suggestion ?

I don't know of any such books, though I'm interested to check out
David Joyner's book, which he advertised in this thread.

William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to