On 3/17/11 11:19 AM, tvn wrote:
I'd expect them to be the same
sage: eval('-1/10')
-1
sage: eval('-(1/10)')
0
Remember that eval doesn't use the Sage preparser, so eval('1/10') is
not the same as 1/10 in Sage, since if you just typed it in Sage, what
is actually run is:
sage: preparse('-1/10')
'-Integer(1)/Integer(10)'
To answer your question, Python by default does integer division (floor
division) if both numerator and denominator are python integers. Thus,
we see that:
sage: eval('(1/10)')
0
since 0 is floor(1/10) (and then your example of -(1/10) is just -0=0).
Likewise, floor(-1/10) is -1.
Thanks,
Jason
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org