Java Bit Unset unsetb(int num, int bitmask)

Here you can find the source of unsetb(int num, int bitmask)

Description

unsetb

License

Apache License

Declaration

public static int unsetb(int num, int bitmask) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int unsetb(int num, int bitmask) {
        if (bset(num, bitmask))
            num -= bitmask;//  w w  w . j a  v a2  s .c o m
        return num;
    }

    public static long unsetb(long num, long bitmask) {
        if (bset(num, bitmask))
            num -= bitmask;
        return num;
    }

    public static long unsetb(long num, int bitmask) {
        if (bset(num, bitmask))
            num -= bitmask;
        return num;
    }

    public static boolean bset(int num, int bitmask) {
        return ((num & bitmask) == bitmask);
    }

    public static boolean bset(long num, long bitmask) {
        return ((num & bitmask) == bitmask);
    }

    public static boolean bset(long num, int bitmask) {
        return ((num & bitmask) == bitmask);
    }
}

Related

  1. unset(byte[] bytes)
  2. UnsetBit(byte _bitset, byte bit)
  3. unsetBit(byte b, int pos)
  4. unsetBit(byte original, int bitToUnSet)
  5. unsetBit(byte[] b, int index)