Java Bit Set setBits(byte in, byte data, int position, int fillBits)

Here you can find the source of setBits(byte in, byte data, int position, int fillBits)

Description

set Bits

License

Open Source License

Declaration

public static byte setBits(byte in, byte data, int position, int fillBits) 

Method Source Code

//package com.java2s;

public class Main {
    public static byte setBits(byte in, byte data, int position, int fillBits) {
        if (position - fillBits == 0) {
            fillBits++;//from  ww w .  j  a va 2 s  .com
        }
        in |= data << 9 - position - fillBits;
        return in;
    }

    public static short setBits(short in, short data, int position, int fillBits) {
        if (position - fillBits == 0) {
            fillBits++;
        }
        in |= data << 17 - position - fillBits;
        return in;
    }
}

Related

  1. setBitInLong(long l, long n, int v)
  2. setBitLE(byte[] data, int index)
  3. setBitmapRange(long[] bitmap, int start, int end)
  4. setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end)
  5. setBitRange(final int val, final int start, final int len, final int newVal)
  6. setBits(final byte value, final int bitMask, final boolean val)
  7. setBits(int lowBit, int numBits)
  8. setBits(int value, int bits)
  9. setBits(long value, long bits)