Java Bit Clean clearBitsAfterInLastWord(int lastWord, int lastSetBit)

Here you can find the source of clearBitsAfterInLastWord(int lastWord, int lastSetBit)

Description

clear Bits After In Last Word

License

Apache License

Declaration

public static int clearBitsAfterInLastWord(int lastWord, int lastSetBit) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//  www .  j  av  a 2 s  . co m
     * Literal that represents all bits set to 0 (and MSB = 1)
     */
    public final static int ALL_ZEROS_LITERAL = 0x80000000;

    public static int clearBitsAfterInLastWord(int lastWord, int lastSetBit) {
        return lastWord &= ALL_ZEROS_LITERAL
                | (0xFFFFFFFF >>> (31 - lastSetBit));
    }
}

Related

  1. clearBit(int value, int index)
  2. clearBit(long n, int i)
  3. clearBit33ofDTS(byte[] array, int offset)
  4. clearBits(int value, int bits)
  5. clearBits(long value, long bits)
  6. clearBitsUpToLS(int n, int i)