Package java.math

Examples of java.math.BigInteger.subtract()


    return BigInt.fromBigInteger(bx.add(BigInteger.ONE));
  }

  public Number dec(Number x){
    BigInteger bx = toBigInteger(x);
    return BigInt.fromBigInteger(bx.subtract(BigInteger.ONE));
  }
}


final static class BigDecimalOps extends OpsP{
View Full Code Here


    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
      for (RoundingMode mode : asList(CEILING, UP)) {
        BigInteger result = BigIntegerMath.sqrt(x, mode);
        assertTrue(result.compareTo(ZERO) > 0);
        assertTrue(result.pow(2).compareTo(x) >= 0);
        assertTrue(result.signum() == 0 || result.subtract(ONE).pow(2).compareTo(x) < 0);
      }
    }
  }

  // Relies on the correctness of sqrt(BigInteger, FLOOR).
View Full Code Here

                    } else {
                        SessionID prev = _model.getSessionIDAt(_key, rowIndex - 1);
                        BigInteger prevValue = _model.getSessionIDValue(_key, prev);
                        BigInteger now = _model.getSessionIDValue(_key,  id);
                        if (now != null && prevValue != null) {
                            return now.subtract(prevValue);
                        } else {
                            return null;
                        }
                    }
                default: return null;
View Full Code Here

            return random.nextBigInteger(numberOfBits);

        BigInteger minToUse = min;
        BigInteger maxToUse = max;
        if (minToUse == null)
            minToUse = maxToUse.subtract(TEN.pow(numberOfBits));
        else if (maxToUse == null)
            maxToUse = minToUse.add(TEN.pow(numberOfBits));

        return Ranges.choose(random, minToUse, maxToUse);
    }
View Full Code Here

            return random.nextBigInteger(numberOfBits);

        BigInteger minToUse = min;
        BigInteger maxToUse = max;
        if (minToUse == null)
            minToUse = maxToUse.subtract(TEN.pow(numberOfBits));
        else if (maxToUse == null)
            maxToUse = minToUse.add(TEN.pow(numberOfBits));

        return Ranges.choose(random, minToUse, maxToUse);
    }
View Full Code Here

     
      NumWithInfo underflow = new NumWithInfo(value.negate().subtract(BigInteger.ONE), bits, true, NumWithInfo.UNDERFLOW);
      NumWithInfo bottom = new NumWithInfo(value.negate(), bits, true, NumWithInfo.NORMAL);
      NumWithInfo nearBottom = new NumWithInfo(value.negate().add(BigInteger.ONE), bits, true, NumWithInfo.NORMAL);
     
      NumWithInfo nearTop = new NumWithInfo(value.subtract(BigInteger.valueOf(2)), bits, false, NumWithInfo.NORMAL);
      NumWithInfo top = new NumWithInfo(value.subtract(BigInteger.ONE), bits, false, NumWithInfo.NORMAL);
      NumWithInfo overflow = new NumWithInfo(value, bits, false, NumWithInfo.OVERFLOW);
     
      infos.add(underflow);
      infos.add(bottom);
View Full Code Here

      NumWithInfo underflow = new NumWithInfo(value.negate().subtract(BigInteger.ONE), bits, true, NumWithInfo.UNDERFLOW);
      NumWithInfo bottom = new NumWithInfo(value.negate(), bits, true, NumWithInfo.NORMAL);
      NumWithInfo nearBottom = new NumWithInfo(value.negate().add(BigInteger.ONE), bits, true, NumWithInfo.NORMAL);
     
      NumWithInfo nearTop = new NumWithInfo(value.subtract(BigInteger.valueOf(2)), bits, false, NumWithInfo.NORMAL);
      NumWithInfo top = new NumWithInfo(value.subtract(BigInteger.ONE), bits, false, NumWithInfo.NORMAL);
      NumWithInfo overflow = new NumWithInfo(value, bits, false, NumWithInfo.OVERFLOW);
     
      infos.add(underflow);
      infos.add(bottom);
      infos.add(nearBottom);
View Full Code Here

        BigInteger startInt = convertIPv6AddressToBigInteger(start);
        BigInteger endInt = convertIPv6AddressToBigInteger(end);
        if (startInt.compareTo(endInt) > 0) {
            return null;
        }
        return endInt.subtract(startInt).add(BigInteger.ONE);
    }

    public static boolean isIp6InRange(String ip6, String ip6Range) {
        if (ip6Range == null) {
            return false;
View Full Code Here

        BigInteger startInt = convertIPv6AddressToBigInteger(start);
        BigInteger endInt = convertIPv6AddressToBigInteger(end);
        if (startInt.compareTo(endInt) > 0) {
            return null;
        }
        return endInt.subtract(startInt).add(BigInteger.ONE);
    }

    public static boolean isIp6InRange(String ip6, String ip6Range) {
        if (ip6Range == null) {
            return false;
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

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.