Java Bit Set setbit(final int num, final int bitnum, final boolean state)

Here you can find the source of setbit(final int num, final int bitnum, final boolean state)

Description

setbit

License

Open Source License

Declaration

public static int setbit(final int num, final int bitnum, final boolean state) 

Method Source Code

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

public class Main {
    public static int setbit(final int num, final int bitnum, final boolean state) {
        return (state) ? (num | (1 << bitnum)) : (num & ~(1 << bitnum));
    }//from   w  w  w.  j  a v  a 2 s .  c o m
}

Related

  1. setBit(byte[] data, int pos, int val)
  2. setBit(byte[] data, long pos, byte val)
  3. setBit(final byte input, final int bit, final boolean status)
  4. setBit(final byte pData, final int pBitIndex, final boolean pOn)
  5. setBit(final byte[] buf, final long bitIndex, final boolean value)
  6. setBit(final int source, final int bit, final boolean value)
  7. setBit(final long word, final int idx, final boolean bit)
  8. setBit(int b0, boolean value, int original)
  9. setBit(int bit)