Package java.math

Examples of java.math.BigInteger.negate()


            radix = Integer.parseInt(m.group(6));
        if(n == null)
            return null;
        BigInteger bn = new BigInteger(n, radix);
        if(negate)
            bn = bn.negate();
        if(m.group(8) != null)
            return BigInt.fromBigInteger(bn);
        return bn.bitLength() < 64 ?
               Numbers.num(bn.longValue())
                                   : BigInt.fromBigInteger(bn);
View Full Code Here


                }
            }
        } else {
            BigInteger bigValue = new BigInteger(numberText, radix);
            if (negative) {
                bigValue = bigValue.negate();
            }

            // Check bounds.
            if (!isLong) {
                if (isSigned) {
View Full Code Here

    for (int i = 1; i < max; i++) {
      BigInteger value = BigInteger.valueOf(2).pow(i);
      int bits = i + 1;
     
      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);
View Full Code Here

    for (int i = 1; i < max; i++) {
      BigInteger value = BigInteger.valueOf(2).pow(i);
      int bits = i + 1;
     
      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);
View Full Code Here

      BigInteger value = BigInteger.valueOf(2).pow(i);
      int bits = i + 1;
     
      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);
     
View Full Code Here

    boolean isNegative = readBooleanAsBit();
    int numOfBitsWithoutSignBit = numOfBits - 1;
    BigInteger finalValue = buffer.read(numOfBitsWithoutSignBit, false, Buffer.BIG_ENDIAN);
   
    if (isNegative) {
      finalValue = finalValue.negate();
    }
   
    return finalValue;
  }
 
View Full Code Here

    boolean isNegative = readBooleanAsBit();
    int numOfBitsWithoutSign = numOfBits - 1;
    BigInteger unscaledValue = buffer.read(numOfBitsWithoutSign, false, Buffer.BIG_ENDIAN);
   
    if (isNegative) {
      unscaledValue = unscaledValue.negate();
    }
   
    return new BigDecimal(unscaledValue, scaleValue);
  }
View Full Code Here

        for (int i=0; i<2000; i++) {
            BigInteger m = new BigInteger(800, rnd);
            BigInteger base = new BigInteger(16, rnd);
            if (rnd.nextInt() % 1 == 0)
                base = base.negate();
            BigInteger exp = new BigInteger(8, rnd);

            BigInteger z = base.modPow(exp, m);
            BigInteger w = base.pow(exp.intValue()).mod(m);
            if (!z.equals(w)){
View Full Code Here

    }
    // convert back to a signed number
    boolean isNegative = result.testBit(0);
    if (isNegative) {
      result = result.add(BigInteger.ONE);
      result = result.negate();
    }
    result = result.shiftRight(1);
    return result;
  }
View Full Code Here

        } else {
            z = new BigInteger(new String(result, 0, resultIndex), base);
        }

        if(!sign) {
            z = z.negate();
        }

        if(badcheck) {
            if(_str.getBegin() + 1 < str && data[str-1] == '_') {
                invalidString("Integer");
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.