logic - how do I find if any bit of x equals 1 in C -
using bit-wise , logical operations, how can detect if bit of x equals 1 in c? no loops, if/else, ==, or !=
someone proposed (x & ~0) && 1, i've been looking @ hours , still don't know how (x & ~0) && 1 can detect if bit of x equals 1
!!x
it.
this convert values 1, except 0 stays 0. , compilers can optimize intelligently.
Comments
Post a Comment