1 | initial version |

This isn't a sagetex-related issue: it's because randint returns a Python int:

```
sage: c = randint(14, 20)
sage: d = randint(5, 10)
sage: c
17
sage: d
7
sage: type(c), type(d)
(<type 'int'>, <type 'int'>)
```

and division of Python ints is truncating:

```
sage: c / d
2
```

The reason that the second one behaves is because the 3 and 1 in `-3`

and `+1`

are Sage Integers, and operations involving them and Python ints produce Sage objects (Integers, Rationals, etc), so things work the way they should:

```
sage: (c-3)/(d+1)
7/4
sage: type(_)
<type 'sage.rings.rational.Rational'>
```

If you wrap the `randint`

call in `Integer`

, it should behave, although I can't do a sagetex test at the moment:

```
sage: c = Integer(randint(14, 20))
sage: c
15
sage: type(c), parent(c)
(<type 'sage.rings.integer.Integer'>, Integer Ring)
```

2 | No.2 Revision |

This isn't a sagetex-related issue: it's because randint returns a Python int:

```
sage: c = randint(14, 20)
sage: d = randint(5, 10)
sage: c
17
sage: d
7
sage: type(c), type(d)
(<type 'int'>, <type 'int'>)
```

and division of Python ints is truncating:

```
sage: c / d
2
```

The reason that the second one behaves is because the 3 and 1 in

and ~~-3~~c-3

are Sage Integers, and operations involving them and Python ints produce Sage objects (Integers, Rationals, etc), so things work the way they should:~~+1~~d+1

```
sage: (c-3)/(d+1)
7/4
sage: type(_)
<type 'sage.rings.rational.Rational'>
```

If you wrap the `randint`

call in `Integer`

, it should behave, although I can't do a sagetex test at the moment:

```
sage: c = Integer(randint(14, 20))
sage: c
15
sage: type(c), parent(c)
(<type 'sage.rings.integer.Integer'>, Integer Ring)
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.