Here you can find the source of setBit(final byte input, final int bit, final boolean status)
public static byte setBit(final byte input, final int bit, final boolean status)
//package com.java2s; //License from project: Open Source License public class Main { public static byte setBit(final byte input, final int bit, final boolean status) { if (status) return (byte) (input | 1 << bit); else// w ww . java 2s. com return (byte) (input & ~(1 << bit)); } public static short setBit(final short input, final int bit, final boolean status) { if (status) return (short) (input | 1 << bit); else return (short) (input & ~(1 << bit)); } public static int setBit(final int input, final int bit, final boolean status) { if (status) return (short) (input | 1 << bit); else return (short) (input & ~(1 << bit)); } }