@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rmod___doc) final PyObject int___rmod__(PyObject left) { if (!canCoerce(left)) { return null; } int leftv = coerce(left); int v = getValue(); return Py.newInteger(modulo(leftv, v, divide(leftv, v))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___mod___doc) final PyObject int___mod__(PyObject right) { if (!canCoerce(right)) { return null; } int rightv = coerce(right); int v = getValue(); return Py.newInteger(modulo(v, rightv, divide(v, rightv))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___divmod___doc) final PyObject int___divmod__(PyObject right) { if (!canCoerce(right)) { return null; } int rightv = coerce(right); int v = getValue(); long xdivy = divide(v, rightv); return new PyTuple(Py.newInteger(xdivy), Py.newInteger(modulo(v, rightv, xdivy))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdivmod___doc) final PyObject int___rdivmod__(PyObject left) { if (!canCoerce(left)) { return null; } int leftv = coerce(left); int v = getValue(); long xdivy = divide(leftv, v); return new PyTuple(Py.newInteger(xdivy), Py.newInteger(modulo(leftv, v, xdivy))); }
result = modulo(result, mod, divide(result, mod));