/* * bitwise.cpp * * Created on: 28.03.2013 * Author: trifon */ #include using namespace std; #include "bitwise.h" void Bitwise::print() const { bitwise y = x; /* for(int i = 0; i < BITS; i++) { cout << y % 2; y /= 2; } */ for(int i = 0; i < BITS; i++) { cout << (y & 1); y >>= 1; } } bool Bitwise::getBit(int i) const { bitwise mask = 1 << i; // !!! return x & mask != 0; // !!! return x & (mask != 0); return (x & mask) != 0; } void Bitwise::setBit(int i) { bitwise mask = 1 << i; x |= mask; } void Bitwise::resetBit(int i) { bitwise mask = ~(1 << i); x &= mask; }