Java Bit Set setBit(int value, int bitmask, boolean set)

Here you can find the source of setBit(int value, int bitmask, boolean set)

Description

set Bit

License

Open Source License

Declaration

public static int setBit(int value, int bitmask, boolean set) 

Method Source Code

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

public class Main {
    public static int setBit(int value, int bitmask, boolean set) {

        if (set) {
            return bitmask | value;
        } else {// www .  j  a v a  2s.co  m
            System.out.println("Reset bit " + value + ": from " + bitmask
                    + " to " + (bitmask & ~value));
            return bitmask & ~value;
        }
    }
}

Related

  1. setBit(int n, int bitPosition)
  2. setBit(int position, boolean value, int meta)
  3. setBit(int position, byte[] array)
  4. setBit(int value, int bit)
  5. setBit(int value, int bitIndex)
  6. setBit(int value, int flags)
  7. setBit(int value, int index)
  8. setBit(int[] x, int i, int v)
  9. setBit(long[] data, int position, int bitWidth)