I have found this if condition using bitwise, I don't know how to convert it to work with normal logical operator.
if (out[currentState] & (1 << j))
How to provide an equivalent condition that doesn't use bitwise?
I have found this if condition using bitwise, I don't know how to convert it to work with normal logical operator.
if (out[currentState] & (1 << j))
How to provide an equivalent condition that doesn't use bitwise?
Bit shifts are basically multiplications and divisions by 2. The above condition is equivalent to
if ((out[currentState] >> j) & 1)
which can be converted to
if ((int)(out[currentState] / pow(2, j)) % 2)
Bitwise operations aren't that difficult to learn, in fact they're much faster than other data type operations. However, you can use a function, to hide the complicated computation, like so:
bool Check( const Foo& foo, int pos) {
return foo & 1 << pos;
if(Check(out[currentState], j)) dosomething();