Package java.math

Examples of java.math.BigInteger.subtract()


    {
        BigInteger min = new BigInteger( Integer.toString( Integer.MIN_VALUE ) );
        assertTrue( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
    }


    @Test
View Full Code Here


    @Test
    public void testMinValueBoundry()
    {
        BigInteger min = new BigInteger( Long.toString( Long.MIN_VALUE ) );
        assertTrue( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
    }
View Full Code Here

    {
        BigInteger min = new BigInteger( Long.toString( Long.MIN_VALUE ) );
        assertTrue( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
        min = min.subtract( BigInteger.ONE );
        assertFalse( checker.isValidSyntax( min.toString() ) );
    }


    @Test
View Full Code Here

            n--;
            if (sBits.size() < n + 1) {
                sBits.setSize(n + 1);
            }
            sBits.set(n, '1');
            s = s.subtract(_TWO.pow(n));
        }
        if (s.equals(BigInteger.ONE)) {
            if (sBits.isEmpty()) {
                sBits.add('1');
            } else {
View Full Code Here

        }

        Tensor toTensor() {
            BigInteger exponent = this.exponent;
            if (minExponent != null && minExponent.value != null) {
                exponent = exponent.subtract(minExponent.value);
                if (diffSigns && minExponent.value.testBit(0))
                    return Tensors.negate(Tensors.pow(tensor, new Complex(exponent)));
            }
            return Tensors.pow(tensor, new Complex(exponent));
        }
View Full Code Here

        }
        BigInteger max = MINUS_ONE;
        for (BigInteger c : ns.values())
            if (c.compareTo(max) > 0)
                max = c;
        return max.subtract(array[0]);

    }

    private static BigInteger frobeniusNumberIntegerArray(BigInteger[] array) {
        int array0 = intValue(array[0]);
View Full Code Here

        for (int i = 0; i < array0; i++)
            if (ns[i].equals(MINUS_ONE) || ns[i].compareTo(max) > 0)
                max = ns[i];
        if (max.equals(MINUS_ONE))
            return MINUS_ONE;
        return max.subtract(array[0]);
    }


    private static BigInteger gcd(BigInteger a, BigInteger b) {
        return a.gcd(b);
View Full Code Here

    public static long ceilDiv(long num, long den) {

        if (Long.MAX_VALUE - num < den - 1L) { // if num + (den - 1) overflows
            final BigInteger bigNum = BigInteger.valueOf(num);
            final BigInteger bigDen = BigInteger.valueOf(den);
            return bigNum.add(bigDen.subtract(BigInteger.ONE)).divide(bigDen).longValue();
        }
        else {
            return (num + (den - 1L)) / den;
        }
    }
View Full Code Here

                if (restrictive) {
                    return context.nil;
                }
                big = big.abs();
            }
            big = big.subtract(BigInteger.ONE);
            return randLimitedBignum(context, random, RubyBignum.newBignum(context.runtime, big));
        }
    }

    public static RubyFloat randFloat(ThreadContext context, RandomType random) {
View Full Code Here

                    }
                } else if (v instanceof RubyBignum) {
                    BigInteger big = ((RubyBignum) v).getBigIntegerValue();
                    if (!big.equals(BigInteger.ZERO) && (big.signum() > 0)) {
                        if (range.excl) {
                            big = big.subtract(BigInteger.ONE);
                        }
                        v = randLimitedBignum(context, random, RubyBignum.newBignum(
                                context.runtime, big));
                    } else {
                        v = context.nil;
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.