Java Bits Convert to bitReverse31(int i)

Here you can find the source of bitReverse31(int i)

Description

Reverse the 31 low order bits used to comprise the integer i.

License

Open Source License

Parameter

Parameter Description
i The integer to reverse the bits of.

Return

The reversed bits.

Declaration

private static final int bitReverse31(int i) 

Method Source Code

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

public class Main {
    /**/*from   ww  w.jav  a2  s  .c o m*/
     * Reverse the 31 low order bits used to comprise the integer i.
     *
     * The highorder bit is ignored because it is the signed bit.
     *
     * @param i The integer to reverse the bits of.
     *
     * @return The reversed bits.
     */
    private static final int bitReverse31(int i) {
        return ((i >>> 30) & 0x00000001) | ((i << 30) & 0x40000000)
                | ((i >>> 28) & 0x00000002) | ((i << 28) & 0x20000000)
                | ((i >>> 26) & 0x00000004) | ((i << 26) & 0x10000000)
                | ((i >>> 24) & 0x00000008) | ((i << 24) & 0x08000000)
                | ((i >>> 22) & 0x00000010) | ((i << 22) & 0x04000000)
                | ((i >>> 20) & 0x00000020) | ((i << 20) & 0x02000000)
                | ((i >>> 18) & 0x00000040) | ((i << 18) & 0x01000000)
                | ((i >>> 16) & 0x00000080) | ((i << 16) & 0x00800000)
                | ((i >>> 14) & 0x00000100) | ((i << 14) & 0x00400000)
                | ((i >>> 12) & 0x00000200) | ((i << 12) & 0x00200000)
                | ((i >>> 10) & 0x00000400) | ((i << 10) & 0x00100000)
                | ((i >>> 8) & 0x00000800) | ((i << 8) & 0x00080000)
                | ((i >>> 6) & 0x00001000) | ((i << 6) & 0x00040000)
                | ((i >>> 4) & 0x00002000) | ((i << 4) & 0x00020000)
                | ((i >>> 2) & 0x00004000) | ((i << 2) & 0x00010000);
    }
}

Related

  1. bitHistogram(int[] data)
  2. 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)
  3. bitmap64(byte... table)
  4. BitPrecisionInt(int numberValue)
  5. bitRangeValueLong(byte[] b, int offset, int length)
  6. bitrv208(double[] a, int offa)
  7. bitrv208neg(double[] a, int offa)
  8. bitrv216neg(double[] a, int offa)
  9. bitrv2conj(int n, int[] ip, double[] a, int offa)