Package java.math

Examples of java.math.BigInteger.negate()


      return;
  }
  final int signum = v.signum();
    BigInteger val = v;
  if (signum < 0) {
        val = val.negate();
  }
    final byte[] magnitude = val.toByteArray();
  final int n = magnitude.length;
  // Reverse the array to make it little endian.
  for (int i = 0, j = n; i < j--; i++) {
View Full Code Here


      index++;
      radix = 8;
    }

    BigInteger result = new BigInteger(value.substring(index), radix);
    return (negative ? result.negate() : result);
  }

}
View Full Code Here

    {
      BinaryDecimal rbd = (BinaryDecimal) result;
     
      BigInteger bi = new BigInteger(data2c);
      // scale remains unchanged.
      rbd.data2c = bi.negate().toByteArray();
      rbd.sqlScale = sqlScale;
   
    }
     
    return result;
View Full Code Here

    if (exponent < 0) {
      return BigInteger.ZERO;
    }
    long significand = getSignificand(x);
    BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
    return (x < 0) ? result.negate() : result;
  }

  /**
   * Returns {@code true} if {@code x} is exactly equal to {@code 2^k} for some finite integer
   * {@code k}.
View Full Code Here

            radix = 8;
            pos ++;
        } // default is to treat as decimal

        final BigInteger value = new BigInteger(str.substring(pos), radix);
        return negate ? value.negate() : value;
    }

    /**
     * <p>Convert a <code>String</code> to a <code>BigDecimal</code>.</p>
     *
 
View Full Code Here

    System.arraycopy(buf, offset, bytes, 0, len);
   
    BigInteger big = new BigInteger(bytes);
   
    if (negative) {
      big = big.negate();
    }
    return big;
  }

  public static void longToBytes(long v, byte[] buf, int offset) {
View Full Code Here

           
        String s;
        if (year.signum() <= 0) {
            // negative value
            buf.append('-');
            s = year.negate().add(BigInteger.ONE).toString();
        } else
            // positive value
            s = year.toString();

        while (s.length() < 4)
View Full Code Here

      index++;
      radix = 8;
    }

    BigInteger result = new BigInteger(value.substring(index), radix);
    return (negative ? result.negate() : result);
  }

}
View Full Code Here

    {
      BinaryDecimal rbd = (BinaryDecimal) result;
     
      BigInteger bi = new BigInteger(data2c);
      // scale remains unchanged.
      rbd.data2c = bi.negate().toByteArray();
      rbd.sqlScale = sqlScale;
   
    }
     
    return result;
View Full Code Here

      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

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.