Monday, 12 March 2012

Classical Programming - 2 : check bit of unsigned integer (c++)

bool isOn(unsigned int val, int bitNo){
  return (val>>bitNo)%2;
}

bool isOff(unsigned int val, int bitNo){
  return !isOn(val, bitNo);
}

No comments:

Post a Comment