On Fri, 15 Dec 2006 19:45:22 -0800, Georg Muntingh <[EMAIL PROTECTED]> wrote:
> A few weeks ago I discovered Sage. By now I've read most of the
> documentation and am very impressed! While playing around with Sage I
> stumbled upon the following: if you convert a string of integers with a
> leading zero into a Sage integer, then Sage treats the string as
> belonging to an octal number. I thought this was confusing. Is this a
> bug, a feature or a Python curiosity? Maybe there should be a warning
> in the FAQ or the tutorial for this?

It is a Python curiosity.  Namely if in pure Python one has:

[EMAIL PROTECTED]:~$ python
Python 2.5 (r25:51908, Dec 13 2006, 18:52:20)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 011
9

---

I've added this to the tutorial:

A Python oddity that is a potential source of confusion is that an
integer literal that begins with a zero is treated as an octal number,
i.e., a number in base 8.
\begin{verbatim}
sage: 011
9
sage: 8 + 1
9
sage: n = 011; n.str(8)
'11'
\end{verbatim}
This is consistent with the C programming language, which treats
integer literals beginning with a 0 as octal numbers.


--~--~---------~--~----~------------~-------~--~----~
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-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to