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

PythonObject // PythonObject -- floor division of Python objects

Description

Divide two Python objects, giving the "floor" quotient, e.g., when dividing two integers, the result is the quotient using Euclidean division.

i1 : toPython 5 // toPython 3

o1 = 1

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 = 1

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

o3 = 1

o3 : PythonObject of class int

Note that the behavior of floor division for integers differs between Macaulay2 and Python. In particular, in Macaulay2, the quotient is rounded down when y is positive and up when y is negative. In Python, the quotient is always rounded down.

i4 : 5 // -3

o4 = -1
i5 : toPython 5 // -3

o5 = -2

o5 : PythonObject of class int

See also

Menu

Ways to use this method:


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