@ExposedMethod(type = MethodType.BINARY, defaults = {"null"}, // doc = BuiltinDocs.int___pow___doc) final PyObject int___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) { return null; } modulo = (modulo == Py.None) ? null : modulo; if (modulo != null && !canCoerce(modulo)) { return null; } return _pow(getValue(), coerce(right), modulo, this, right); }
@Override public PyObject __rpow__(PyObject left) { if (!canCoerce(left)) { return null; } return _pow(coerce(left), getValue(), null, left, this); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rsub___doc) final PyObject int___rsub__(PyObject left) { if (!canCoerce(left)) { return null; } return _sub(coerce(left), getValue()); }
@ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.int___cmp___doc) final int int___cmp__(PyObject other) { if (!canCoerce(other)) { return -2; } int v = coerce(other); return getValue() < v ? -1 : getValue() > v ? 1 : 0; }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___sub___doc) final PyObject int___sub__(PyObject right) { if (!canCoerce(right)) { return null; } return _sub(getValue(), coerce(right)); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___floordiv___doc) final PyObject int___floordiv__(PyObject right) { if (!canCoerce(right)) { return null; } return Py.newInteger(divide(getValue(), coerce(right))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rfloordiv___doc) final PyObject int___rfloordiv__(PyObject left) { if (!canCoerce(left)) { return null; } return Py.newInteger(divide(coerce(left), getValue())); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___add___doc) final PyObject int___add__(PyObject right) { if (!canCoerce(right)) { return null; } int rightv = coerce(right); int a = getValue(); int b = rightv; int x = a + b; if ((x ^ a) >= 0 || (x ^ b) >= 0) { return Py.newInteger(x); } return new PyLong((long)a + (long)b); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdiv___doc) final PyObject int___rdiv__(PyObject left) { if (!canCoerce(left)) { return null; } if (Options.division_warning > 0) { Py.warning(Py.DeprecationWarning, "classic int division"); } return Py.newInteger(divide(coerce(left), getValue())); }
@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___div___doc) final PyObject int___div__(PyObject right) { if (!canCoerce(right)) { return null; } if (Options.division_warning > 0) { Py.warning(Py.DeprecationWarning, "classic int division"); } return Py.newInteger(divide(getValue(), coerce(right))); }
@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___mul___doc) final PyObject int___mul__(PyObject right) { if (!canCoerce(right)) { return null; } int rightv = coerce(right); double x = getValue(); x *= rightv; if (x <= Integer.MAX_VALUE && x >= Integer.MIN_VALUE) { return Py.newInteger((int)x); } return __long__().__mul__(right); }
@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))); }