⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pylong.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        ad /= bd;        int aexp = ae[0]-be[0];                if (aexp > Integer.MAX_VALUE/8) {            throw Py.OverflowError("long/long too large for a float");        } else if ( aexp < -(Integer.MAX_VALUE/8)) {            return new PyFloat(0.0);        }                ad = ad * Math.pow(2.0, aexp*8);                if (Double.isInfinite(ad)) {            throw Py.OverflowError("long/long too large for a float");        }                       return new PyFloat(ad);            }    public PyObject __truediv__(PyObject right) {        if (!canCoerce(right))            return null;        return true_divide(this.value,coerce(right));    }    public PyObject __rtruediv__(PyObject left) {        if (!canCoerce(left))            return null;        return true_divide(coerce(left),this.value);    }    private BigInteger modulo(BigInteger x, BigInteger y, BigInteger xdivy) {        return x.subtract(xdivy.multiply(y));    }    public PyObject __mod__(PyObject right) {        if (!canCoerce(right))            return null;        BigInteger rightv = coerce(right);        return new PyLong(modulo(value, rightv, divide(value, rightv)));    }    public PyObject __rmod__(PyObject left) {        if (!canCoerce(left))            return null;        BigInteger leftv = coerce(left);        return new PyLong(modulo(leftv, value, divide(leftv, value)));    }    public PyObject __divmod__(PyObject right) {        if (!canCoerce(right))            return null;        BigInteger rightv = coerce(right);        BigInteger xdivy = divide(value, rightv);        return new PyTuple(new PyObject[] {            new PyLong(xdivy),            new PyLong(modulo(value, rightv, xdivy))        });    }    public PyObject __rdivmod__(PyObject left) {        if (!canCoerce(left))            return null;        BigInteger leftv = coerce(left);        BigInteger xdivy = divide(leftv, value);        return new PyTuple(new PyObject[] {            new PyLong(xdivy),            new PyLong(modulo(leftv, value, xdivy))        });    }    public PyObject __pow__(PyObject right, PyObject modulo) {        if (!canCoerce(right))            return null;        if (modulo != null && !canCoerce(right))            return null;        return _pow(value, coerce(right), modulo, this, right);    }    public PyObject __rpow__(PyObject left) {        if (!canCoerce(left))            return null;        return _pow(coerce(left), value, null, left, this);    }    public static PyObject _pow(BigInteger value, BigInteger y,                                PyObject modulo, PyObject left, PyObject right)    {        if (y.compareTo(BigInteger.valueOf(0)) < 0) {            if (value.compareTo(BigInteger.valueOf(0)) != 0)                return left.__float__().__pow__(right, modulo);            else                throw Py.ZeroDivisionError("zero to a negative power");        }        if (modulo == null)            return new PyLong(value.pow(y.intValue()));        else {            // This whole thing can be trivially rewritten after bugs            // in modPow are fixed by SUN            BigInteger z = coerce(modulo);            int zi = z.intValue();            // Clear up some special cases right away            if (zi == 0)                throw Py.ValueError("pow(x, y, z) with z == 0");            if (zi == 1 || zi == -1)                return new PyLong(0);            if (z.compareTo(BigInteger.valueOf(0)) <= 0) {                // Handle negative modulo's specially                /*if (z.compareTo(BigInteger.valueOf(0)) == 0) {                  throw Py.ValueError("pow(x, y, z) with z == 0");                  }*/                y = value.modPow(y, z.negate());                if (y.compareTo(BigInteger.valueOf(0)) > 0) {                    return new PyLong(z.add(y));                } else {                    return new PyLong(y);                }                //return __pow__(right).__mod__(modulo);            } else {                // This is buggy in SUN's jdk1.1.5                // Extra __mod__ improves things slightly                return new PyLong(value.modPow(y, z));                //return __pow__(right).__mod__(modulo);            }        }    }    private static final int coerceInt(PyObject other) {        if (other instanceof PyLong)            return (int) ((PyLong) other).getLong(                          Integer.MIN_VALUE, Integer.MAX_VALUE);        else if (other instanceof PyInteger)            return ((PyInteger) other).getValue();        else            throw Py.TypeError("xxx");    }    public PyObject __lshift__(PyObject right) {        if (!canCoerce(right))            return null;        int rightv = coerceInt(right);        if(rightv < 0)            throw Py.ValueError("negative shift count");        return new PyLong(value.shiftLeft(rightv));    }    public PyObject __rshift__(PyObject right) {        if (!canCoerce(right))            return null;        int rightv = coerceInt(right);        if(rightv < 0)            throw Py.ValueError("negative shift count");        return new PyLong(value.shiftRight(rightv));    }    public PyObject __and__(PyObject right) {        if (!canCoerce(right))            return null;        return new PyLong(value.and(coerce(right)));    }    public PyObject __rand__(PyObject left) {        if (!canCoerce(left))            return null;        return new PyLong(coerce(left).and(value));    }    public PyObject __xor__(PyObject right) {        if (!canCoerce(right))            return null;        return new PyLong(value.xor(coerce(right)));    }    public PyObject __rxor__(PyObject left) {        if (!canCoerce(left))            return null;        return new PyLong(coerce(left).xor(value));    }    public PyObject __or__(PyObject right) {        if (!canCoerce(right))            return null;        return new PyLong(value.or(coerce(right)));    }    public PyObject __ror__(PyObject left) {        if (!canCoerce(left))            return null;        return new PyLong(coerce(left).or(value));    }    public PyObject __neg__() {        return new PyLong(value.negate());    }    public PyObject __pos__() {        return this;    }    public PyObject __abs__() {        return new PyLong(value.abs());    }    public PyObject __invert__() {        return new PyLong(value.not());    }    public PyInteger __int__() {        return new PyInteger((int)getLong(Integer.MIN_VALUE,                                          Integer.MAX_VALUE));    }    public PyLong __long__() {        return this;    }    public PyFloat __float__() {        return new PyFloat(doubleValue());    }    public PyComplex __complex__() {        return new PyComplex(doubleValue(), 0.);    }    public PyString __oct__() {        String s = value.toString(8);        if (s.startsWith("-"))            return new PyString("-0"+s.substring(1, s.length())+"L");        else            if (s.startsWith("0"))                return new PyString(s+"L");            else                return new PyString("0"+s+"L");    }    public PyString __hex__() {        String s = value.toString(16).toUpperCase();        if (s.startsWith("-"))            return new PyString("-0x"+s.substring(1, s.length())+"L");        else            return new PyString("0x"+s+"L");    }    public PyString __str__() {        return Py.newString(value.toString());    }    public boolean isMappingType() { return false; }    public boolean isSequenceType() { return false; }    // __class__ boilerplate -- see PyObject for details    public static PyClass __class__;    protected PyClass getPyClass() {        return __class__;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -