Java Bit Set setBit(byte data, byte bit, boolean value)

Here you can find the source of setBit(byte data, byte bit, boolean value)

Description

set Bit

License

Open Source License

Declaration

public static byte setBit(byte data, byte bit, boolean value) 

Method Source Code

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

public class Main {
    public static byte setBit(byte data, byte bit, boolean value) {
        if (value) {
            data = (byte) (data | (1 << bit));
        } else {/*from   w w  w .  ja v  a  2  s . c om*/
            data = (byte) (data & ~(1 << bit));
        }

        return data;
    }
}

Related

  1. SetBit(byte _bitset, byte bit)
  2. setBit(byte _byte, int position, boolean value)
  3. setBit(byte a, int pos, boolean set)
  4. setBit(byte b, int i)
  5. setBit(byte b, int pos)
  6. setBit(byte data, int bitNumber, boolean value)
  7. setBit(byte data, int bitPos, boolean on)
  8. setBit(byte data, int pos, int val)
  9. setBit(byte in, int position, boolean value)