Examples of bitCount()


Examples of java.math.BigInteger.bitCount()

            }

            if (paramValue instanceof BigDecimal) {
                BigDecimal decimal = (BigDecimal) paramValue;
                BigInteger bigInt = decimal.setScale(0,  BigDecimal.ROUND_HALF_UP).toBigInteger();
                return bigInt.bitCount();
            }
            Long val = SQLEvalVisitorUtils.castToLong(paramValue);
            return Long.bitCount(val);
        }
       
View Full Code Here

Examples of java.math.BigInteger.bitCount()

    bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
    bb.position(0);
    bb.limit(8);
    BigInteger bi = Unsigned.getUnsignedLong(bb);
    BigInteger uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());
View Full Code Here

Examples of java.math.BigInteger.bitCount()

    bb.put((byte)0x00);
    bb.position(0);
    bb.limit(10);
    bi = Unsigned.getUnsignedLong(bb, 1);
    uLongMax = new BigInteger(ULONG_MAX);
    for (int i = 0; i < uLongMax.bitCount(); ++i) {
        TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
                uLongMax.testBit(i) == bi.testBit(i));
    }
    TestCase.assertEquals(ULONG_MAX, bi.toString());
  }
View Full Code Here

Examples of org.jenetics.BitChromosome.bitCount()

{
  @Override
  public Integer apply(final Genotype<BitGene> genotype) {
    final BitChromosome chromosome =
      (BitChromosome)genotype.getChromosome();
    return chromosome.bitCount();
  }
}

public class OnesCounting {
  public static void main(String[] args) {
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.