Java Bit Count countBits (long v)

Here you can find the source of countBits (long v)

Description

count Bits

License

Apache License

Declaration

private static int countBits (long v)
    

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file

public class Main {
    private static int countBits(long v) {
        int count = 0;

        for (; v > 0; v = v / 2) {
            ++count;// w w w .j a  va2s  .c  o m
        }

        return count;
    }
}

Related

  1. bitLength(final int byteLength)
  2. bitLength(int num)
  3. bitLength(int value)
  4. bitSizeForSignedValue(final int value)
  5. bitSizeForUnsignedValue(final int value)
  6. countBits(byte num)
  7. countBits(final int intValue)
  8. countBits(int i)
  9. countBits(int mask)