You don't actually say what you find weird about your output, so I had
to look at it for a while before coming up with something.  I'm
guessing it's how the division is behaving?

`randint` returns a Python int:

sage: randint(1, 10)
7
sage: type(randint(1, 10))
<type 'int'>

And division of Python ints is truncating:

sage: int(7)/int(10)
0

Unlike where Sage capital-I integers are involved in the division:

sage: Integer(7)/Integer(10)
7/10
sage: Integer(7)/int(10)
7/10

IOW, Python integer division behaves as "//", not "/".

One way to deal with the problem would be to wrap the results of
randint with a call to ZZ (the Sage Integer ring):

sage: a = randint(1,10); b = randint(1, 10)
sage: a, b, a/b
(3, 5, 0)
sage: a = ZZ(randint(1,10)); b = ZZ(randint(1, 10))
sage: a, b, a/b
(5, 6, 5/6)


Doug

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
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.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to