Java Zero Format zeroCount(long n)

Here you can find the source of zeroCount(long n)

Description

zero Count

License

Open Source License

Declaration

static public int zeroCount(long n) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static public int zeroCount(long n) {
        long k;/*  w w w.j a  v a2  s.  com*/
        int count = 63;

        if (n == 0) {
            return 64;
        }

        k = n << 32;
        if (k != 0) {
            count -= 32;
            n = k;
        }

        k = n << 16;
        if (k != 0) {
            count -= 16;
            n = k;
        }

        k = n << 8;
        if (k != 0) {
            count -= 8;
            n = k;
        }

        k = n << 4;
        if (k != 0) {
            count -= 4;
            n = k;
        }

        k = n << 2;
        if (k != 0) {
            count -= 2;
            n = k;
        }

        k = n << 1;
        if (k != 0) {
            count -= 1;
            n = k;
        }

        return count;
    }
}

Related

  1. zeroAlign(String x, int count)
  2. zeroBasedTemplateStart(final int[] actions)
  3. zeroBlock(byte[] block, int off, int len)
  4. zeroConvert(String src)
  5. zerocount(int v)
  6. zeroDiv(double numerator, double denominator)
  7. zeroes(final int ch)
  8. zeroEsquerda(String s1, int tamString)
  9. zeroExtend(long value, int inputBits)