unset Bit on byte value - Java File Path IO

Java examples for File Path IO:Byte Array

Description

unset Bit on byte value

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte b = 2;
        int pos = 2;
        System.out.println(unsetBit(b, pos));
    }/*  w  ww.ja  va  2  s .  c om*/

    /**
     *
     * @param b
     * @param pos
     * @return
     */
    public static byte unsetBit(byte b, int pos) {
        return (byte) (b & ~(1 << pos));
    }
}

Related Tutorials