Examples of bitCount()


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());
    }

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

Examples of java.math.BigInteger.bitCount()

        return Long.bitCount(a ^ b);
    }

    public static int hammingDistance(final BigInteger a, final BigInteger b) {
        BigInteger xor = a.xor(b);
        return xor.bitCount();
    }

}
View Full Code Here

Examples of java.math.BigInteger.bitCount()

        return val(Long.bitCount(a));
    }

    public IntWritable evaluate(String a) {
        BigInteger ai = new BigInteger(a);
        return val(ai.bitCount());
    }

    public IntWritable evaluate(List<Long> a) {
        int result = 0;
        for(int i = 0; i < a.size(); i++) {
View Full Code Here

Examples of java.math.BigInteger.bitCount()

     */
    public IntWritable evaluate(String a, String b) {
        BigInteger ai = new BigInteger(a);
        BigInteger bi = new BigInteger(b);
        BigInteger innerProduct = ai.and(bi);
        return val(innerProduct.bitCount());
    }

    /**
     * Count bits that both bits are 1.
     */
 
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()

        @Override
        public int hashCode()
        {
            byte[] bytes = name.toString().getBytes();
            BigInteger bigInt = new BigInteger(bytes);
            int val = bigInt.bitCount()+bigInt.intValue();
            return val+idx;
        }

        @Override
        public String toString()
View Full Code Here

Examples of java.math.BigInteger.bitCount()

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

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

Examples of java.math.BigInteger.bitCount()

     * bitCount() of a negative number.
     */
    @Test
    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.
     */
    @Test
    public void testBitCountPos() {
        BigInteger aNumber = new BigInteger("12378634756343564757582937873487638746283767238657872368748726875");
        assertEquals(107, aNumber.bitCount());
    }

    /**
     * bitLength() of zero.
     */
 
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.