Java Bits Convert to BitPrecisionInt(int numberValue)

Here you can find the source of BitPrecisionInt(int numberValue)

Description

Bit Precision Int

License

Creative Commons License

Declaration

static int BitPrecisionInt(int numberValue) 

Method Source Code

//package com.java2s;

public class Main {
    static int BitPrecisionInt(int numberValue) {
        if (numberValue == 0) {
            return 0;
        }/*from   w  ww .j a va  2 s.c o  m*/
        int i = 32;
        {
            if ((numberValue >> 16) == 0) {
                numberValue <<= 16;
                i -= 8;
            }
            if ((numberValue >> 24) == 0) {
                numberValue <<= 8;
                i -= 8;
            }
            if ((numberValue >> 28) == 0) {
                numberValue <<= 4;
                i -= 4;
            }
            if ((numberValue >> 30) == 0) {
                numberValue <<= 2;
                i -= 2;
            }
            if ((numberValue >> 31) == 0) {
                --i;
            }
        }
        return i;
    }
}

Related

  1. bitfieldToString(String[] statenames, int value)
  2. bitFlagByteLength(final int nbits)
  3. bitHistogram(int[] data)
  4. bitMap(final boolean v1, final boolean v2, final boolean v3, final boolean v4, final boolean v5, final boolean v6, final boolean v7, final boolean v8)
  5. bitmap64(byte... table)
  6. bitRangeValueLong(byte[] b, int offset, int length)
  7. bitReverse31(int i)
  8. bitrv208(double[] a, int offa)
  9. bitrv208neg(double[] a, int offa)