Flip bit at pos 1<->0.
761585
def _invert(self, pos):
        """"""
        assert 0 <= pos < self.len
        self._datastore.invertbit(pos)
720427
def gray(num_bits):
    
    last = 0
    x = 0
    n = 1 << num_bits
    while n > x:
        bit_string = bin(n + x ^ x // 2)[3:]
        value = int(bit_string, 2)
        yield bit_string, value, changed_bit_pos(last, value)
        last = value
        x += 1
519374
function setBit (buffer, pos, bit) {
  const byte = Math.floor(pos / 8)
  const bitPos = pos % 8

  if (bit === 0) {
    const mask = 255 - (1 << bitPos)
    buffer[byte] &= mask
  } else {
    const mask = (1 << bitPos)
    buffer[byte] |= mask
  }
}
55046
def bitphase_flip_operators(p):
    
    k0 = np.sqrt(1 - p) * I
    k1 = np.sqrt(p) * Y
    return k0, k1
1004205
def _setsie(self, i):
        """"""
        if not i:
            self._setbin_unsafe('1')
        else:
            self._setuie(abs(i))
            self._append(Bits([i < 0]))
563383
public int peekRawUInt(int bits) throws IOException {
        int val = 0;
        for (int i = 0; i < bits; i++) {
            val = peekBitToInt(val, i);
        }
        return val;
    }
806870
private int resetbuf(int bit_pos) {
		int pos = bit_pos >> 3;
		System.arraycopy(data, pos, data, 0, end - pos);
		end -= pos;
		return 0;
	}
1169036
def rotate(r, pos)
      return (0..2).map do |i|
        (0..2).inject(0) { |sum, j| sum + r[i][j] * pos[j] }
      end
    rescue => e
      raise
    end
155155
def set_bit(bitmask, bit, is_on):
    
    bitshift = bit - 1
    if is_on:
        return bitmask | (1 << bitshift)
    return bitmask & (0xff & ~(1 << bitshift))
88539
def flip(self, axis=0, preserve_centroid=False):
        '''
        

        '''
        self.v[:, axis] *= -1

        if preserve_centroid:
            self.v[:, axis] -= 2 * self.centroid[0]

        self.flip_faces()
161916
def rev_twos_comp_repr(val, bitwidth):
    
    valbl = val.bit_length()
    if bitwidth < val.bit_length() or val == 2**(bitwidth-1):
        raise pyrtl.PyrtlError("please choose a larger target bitwidth")
    if bitwidth == valbl:  # MSB is a 1, value is negative
        return -((~val & (2**bitwidth-1)) + 1)  # flip the bits, add one, and make negative
    else:
        return val
659172
def seek(self, offset, whence=0):
        '''
        
        '''
        if whence == 0:
            self._pos = self._start_pos + offset
        elif whence == 1:
            self._pos += offset
        else:
            self._pos = (self._end_pos - 1) + offset
124818
def getbit(self, key, offset):
        
        key = self._encode(key)
        index, bits, mask = self._get_bits_and_offset(key, offset)

        if index >= len(bits):
            return 0

        return 1 if (bits[index] & mask) else 0
119807
def _write4bits(self, value):
        """"""
        for i in range(4):
            bit = (value >> i) & 0x01
            GPIO.output(self.pins[i + 7], bit)
        self._pulse_enable()
1061985
void flip(long index) {
		assert index >= 0 && index < numBits : "index=" + index + " numBits=" + numBits;
		int wordNum = (int) (index >> 6); // div 64
		long bitmask = 1L << index; // mod 64 is implicit
		bits[wordNum] ^= bitmask;
	}
1283322
def set_bit(self, position: int):
        
        if position > (self._bit_width - 1):
            raise ValueError('position greater than the bit width')

        self._value |= (1 << position)
        self._text_update()
54088
public void fill_1(byte[] v, int byteoff, int nbits, int bitoff) {
      if (nbits < 0) throw new NegativeArraySizeException("nbits < 0: " + nbits);
      if (byteoff < 0) throw new IndexOutOfBoundsException("byteoff < 0: "+ byteoff);
      if (bitoff < 0) throw new IndexOutOfBoundsException("bitoff < 0: " + bitoff);
      assert v == null || byteoff + ((nbits-1) >> 3) + 1 <= v.length;
      _val = v;
      _nbits = nbits;
      _bitoff = bitoff;
      _byteoff = byteoff;
    }