I'm trying to do bit logic manipulation in C but getting stuck. I need to write a function that, given an input argument it will evaluate if my argument has all even bits set to 1. For example:
myFunction (0xFFFFFFFE) = 0;
myFunction (0x55555555) = 1;
The operators that I'm permitted to use are: !
~
&
^
|
+
<<
>>
. I can't use if
statements, loops, or equality checks (so no ==
or !=
operators).