Sets the "bitNo" bit of val to the "bitVal" value:
unsigned int setBit(unsigned int val, unsigned int bitNo, bool bitVal){
if(bitVal) {
val = val | (1 << bitNo);
}
else {
val = val & ~(1 << bitNo);
}
return val;
}
No comments:
Post a Comment