Package java.math

Examples of java.math.BigInteger.subtract()


            fieldUndefined[MONTH] = true;
        }

        BigInteger dMonths = sanitize(duration.getField(DatatypeConstants.MONTHS), signum);
        BigInteger temp = BigInteger.valueOf((long) startMonth).add(dMonths);
        setMonth(temp.subtract(BigInteger.ONE).mod(TWELVE).intValue() + 1);
        BigInteger carry =
                new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_FLOOR).toBigInteger();

        /* Years (may be modified additionally below)
            *  E[year] := S[year] + D[year] + carry
View Full Code Here


            fieldUndefined[MONTH] = true;
        }

        BigInteger dMonths = sanitize(duration.getField(DatatypeConstants.MONTHS), signum);
        BigInteger temp = BigInteger.valueOf((long) startMonth).add(dMonths);
        setMonth(temp.subtract(BigInteger.ONE).mod(TWELVE).intValue() + 1);
        BigInteger carry =
                new BigDecimal(temp.subtract(BigInteger.ONE)).divide(new BigDecimal(TWELVE), BigDecimal.ROUND_FLOOR).toBigInteger();

        /* Years (may be modified additionally below)
            *  E[year] := S[year] + D[year] + carry
View Full Code Here

        /* a for-loop   (i=2;i<= truek;i++)
                */
        for (; i.compareTo(truek) <= 0; i = i.add(BigInteger.ONE)) {
            /* num = n-i+1 after this operation
                        */
            num = num.subtract(BigInteger.ONE);
            /* multiply by (n-i+1)/i
                        */
            bin = (bin.multiply(num)).divide(i);
        }
        return (bin);
View Full Code Here

                        */
            BigInteger x2 = x.pow(2);
            BigInteger xplus2 = x.add(BigInteger.ONE).pow(2);
            if (x2.compareTo(n) <= 0 && xplus2.compareTo(n) > 0)
                return x;
            xplus2 = xplus2.subtract(x.shiftLeft(2));
            if (xplus2.compareTo(n) <= 0 && x2.compareTo(n) > 0)
                return x.subtract(BigInteger.ONE);
            /* Newton algorithm. This correction is on the
                        * low side caused by the integer divisions. So the value required
                        * may end up by one unit too large by the bare algorithm, and this
View Full Code Here

        if (rL == 1)
            return A[0][0];

        else if (rL == 2) {
            d = A[0][0].multiply(A[1][1]);
            return d.subtract(A[0][1].multiply(A[1][0]));
        }
        else {
            /* Work arbitrarily along the first column of the matrix */
            for (int r = 0; r < rL; r++) {
                /* Do not consider minors that do no contribute anyway
View Full Code Here

    static public BigInteger binomial(final int n, final int k) {
        if (k == 0)
            return (BigInteger.ONE);
        BigInteger bin = new BigInteger("" + n);
        BigInteger n2 = bin;
        for (BigInteger i = new BigInteger("" + (k - 1)); i.compareTo(BigInteger.ONE) >= 0; i = i.subtract(BigInteger.ONE))
            bin = bin.multiply(n2.subtract(i));
        for (BigInteger i = new BigInteger("" + k); i.compareTo(BigInteger.ONE) == 1; i = i.subtract(BigInteger.ONE))
            bin = bin.divide(i);
        return (bin);
    } /* binomial */
 
View Full Code Here

            return (BigInteger.ONE);
        BigInteger bin = new BigInteger("" + n);
        BigInteger n2 = bin;
        for (BigInteger i = new BigInteger("" + (k - 1)); i.compareTo(BigInteger.ONE) >= 0; i = i.subtract(BigInteger.ONE))
            bin = bin.multiply(n2.subtract(i));
        for (BigInteger i = new BigInteger("" + k); i.compareTo(BigInteger.ONE) == 1; i = i.subtract(BigInteger.ONE))
            bin = bin.divide(i);
        return (bin);
    } /* binomial */

    /** Evaluate binomial(n,k).
View Full Code Here

                if ( m.compareTo(BigInteger.ZERO) == 0 )
                        return Rational.ONE ;
                Rational bin = n ;
                for(BigInteger i=new BigInteger("2") ; i.compareTo(m) != 1 ; i = i.add(BigInteger.ONE) )
                {
                        bin = bin.multiply(n.subtract(i.subtract(BigInteger.ONE))).divide(i) ;
                }
                return bin ;
        } /* Rational.binomial */

        /** binomial (n choose m).
View Full Code Here

        /*
         * s'il y a au moins un argument, on considère la forme (- n [args...])...
         */
        BigInteger r = number.get();
        for (int i = 1; i < asize; )
            r = r.subtract(_getArg_(startAt, i++));
        return Node.createExternal(new External_Integer(r));
    }

    /**
     * surcharge de l'opérateur -!
View Full Code Here

        BigInteger r;
        do {
            old_r = number.get();
            r = old_r;
            for (int i = 0; i < v.length; i++)
                r = r.subtract(v[i]);
        }
        while (!number.compareAndSet(old_r, r));
        return null;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.