Ask Your Question

Revision history [back]

The function Mod is intended to be used with integers. In order to use mod 1 operations you should use % (which stands for remainder of the euclidean division) as in

sage: sage: 5.3 % 1.0
0.300000000000000

The operation Mod is to be used when you want to work with integers mod N (ie the ring $\mathbb{Z} / N \mathbb{Z}$).

Note that the following works

sage: K.<sqrt5> = NumberField(x^2-5,'sqrt5',embedding=1)
sage: sqrt5 % 1.0
0.236067977499790

But not this one

sage: sqrt(5) % 1.0
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for %: 'sage.symbolic.expression.Expression' and 'sage.symbolic.expression.Expression'