Macaulay2 » Documentation
Packages » Python » PythonObject » PythonObject % PythonObject
next | previous | forward | backward | up | index | toc

PythonObject % PythonObject -- the modulo operator for Python objects

Description

Perform the modulo operator on Python objects.

i1 : toPython 5 % toPython 3

o1 = 2

o1 : PythonObject of class int

If one of the arguments is a Macaulay2 object, then it is first converted to a Python object before dividing.

i2 : toPython 9 % 5

o2 = 4

o2 : PythonObject of class int
i3 : 11 % toPython 7

o3 = 4

o3 : PythonObject of class int

Note that the behavior of the modulo operator for integers differs between Macaulay2 and Python. In particular, in Macaulay2, the remainder is always nonnegative. In Python, the remainder will have the same sign as y.

i4 : 5 % -3

o4 = 2
i5 : toPython 5 % -3

o5 = -1

o5 : PythonObject of class int

See also

Menu

Ways to use this method:


The source of this document is in Python/doc/arithmetic.m2:623:0.