Examples of bitCount()


Examples of java.math.BigInteger.bitCount()

        System.out.println(" BitCount:   " + _value.bitCount());
        System.out.println(" BitLength   " + _value.bitLength());

        BigInteger j = _value.abs();
        System.out.println(" ABS value   " + j.toString(2));
        System.out.println(" ABS bit count:  " + j.bitCount());
        System.out.println(" ABD bitLength:  " + j.bitLength());
        System.out.println(" Max value:  "
                + getPrecision().findMaximum().doubleValue());
        System.out.println(" Min value:  "
                + getPrecision().findMinimum().doubleValue());
View Full Code Here

Examples of java.math.BigInteger.bitCount()

  @GwtIncompatible("java.math.BigInteger")
  public void testIsPowerOfTwo() {
    for (int x : ALL_INTEGER_CANDIDATES) {
      // Checks for a single bit set.
      BigInteger bigX = BigInteger.valueOf(x);
      boolean expected = (bigX.signum() > 0) && (bigX.bitCount() == 1);
      assertEquals(expected, IntMath.isPowerOfTwo(x));
    }
  }

  public void testLog2ZeroAlwaysThrows() {
View Full Code Here

Examples of java.math.BigInteger.bitCount()

  @GwtIncompatible("java.math.BigInteger")
  public void testIsPowerOfTwo() {
    for (long x : ALL_LONG_CANDIDATES) {
      // Checks for a single bit set.
      BigInteger bigX = BigInteger.valueOf(x);
      boolean expected = (bigX.signum() > 0) && (bigX.bitCount() == 1);
      assertEquals(expected, LongMath.isPowerOfTwo(x));
    }
  }

  public void testLog2ZeroAlwaysThrows() {
View Full Code Here

Examples of java.math.BigInteger.bitCount()

    }

    public static UnsignedLong valueOf(final String value)
    {
        BigInteger bigInt = new BigInteger(value);
        if(bigInt.signum() == -1 || bigInt.bitCount()>64)
        {
            throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0L + "- 2^64).");
        }
        else if(bigInt.compareTo(LONG_MAX_VALUE)>=0)
        {
View Full Code Here

Examples of java.math.BigInteger.bitCount()

    }

    public static UnsignedLong valueOf(final String value)
    {
        BigInteger bigInt = new BigInteger(value);
        if(bigInt.signum() == -1 || bigInt.bitCount()>64)
        {
            throw new NumberFormatException("Value \""+value+"\" lies outside the range [" + 0L + "- 2^64).");
        }
        else if(bigInt.compareTo(LONG_MAX_VALUE)>=0)
        {
View Full Code Here

Examples of java.math.BigInteger.bitCount()

  }

  // slow version used for testing
  static long gcd(long l1, long l2) {
    final BigInteger gcd = BigInteger.valueOf(l1).gcd(BigInteger.valueOf(l2));
    assert gcd.bitCount() <= 64;
    return gcd.longValue();
  }

  public void testGCD() {
    final int iters = atLeast(100);
View Full Code Here

Examples of java.math.BigInteger.bitCount()

   * bitCount() of a negative number.
   */
  public void testBitCountNeg() {
    BigInteger aNumber = new BigInteger(
        "-12378634756382937873487638746283767238657872368748726875");
    assertEquals(87, aNumber.bitCount());
  }

  /**
   * bitCount() of a negative number.
   */
 
View Full Code Here

Examples of java.math.BigInteger.bitCount()

   * bitCount() of a negative number.
   */
  public void testBitCountPos() {
    BigInteger aNumber = new BigInteger(
        "12378634756343564757582937873487638746283767238657872368748726875");
    assertEquals(107, aNumber.bitCount());
  }

  /**
   * bitCount() of zero.
   */
 
View Full Code Here

Examples of java.math.BigInteger.bitCount()

  /**
   * bitCount() of zero.
   */
  public void testBitCountZero() {
    BigInteger aNumber = new BigInteger("0");
    assertEquals(0, aNumber.bitCount());
  }

  /**
   * bitLength() of a negative number.
   */
 
View Full Code Here

Examples of java.math.BigInteger.bitCount()

    /**
     * bitCount() of zero.
     */
    public void testBitCountZero() {
        BigInteger aNumber = new BigInteger("0");
        assertEquals(0, aNumber.bitCount());
    }

    /**
     * bitCount() of a negative number.
     */
 
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.