I've got just a simple question about bitwise AND in C++. I'm using it for single bits (a&8, a&4, a&2, a&1, etc.) and I want to get bool value as a return (if there's 1 on the position).
I may divide it by a number (like (a&8)/8), but it dosn't really look nice in my code (especially, that I'm using arrays and long names of variables).
Is there any other, better, way to code it?
Thanks in advance.
bool bTrue = (a & 8);should be good enough or evenbool bTrue = (a & 8) != 0;.trueorfalsein the right context without dividing or any other manipulations.