Here you can find the source of setBit(byte value, int bit, boolean state)
Parameter | Description |
---|---|
value | Value to change. |
bit | Bit to change. |
state | New value of the bit. |
public static byte setBit(byte value, int bit, boolean state)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww . j a v a 2s.c o m * Sets the given bit in the given value. * @param value Value to change. * @param bit Bit to change. * @param state New value of the bit. * @return The resulting value. */ public static byte setBit(byte value, int bit, boolean state) { return state ? (byte) (value | bit) : (byte) (value & ~bit); } }