In the following code:
Expression<Func<int, bool>> isOdd = i => (i & 1) == 1;
...what is the meaning of (i & 1) == 1
?
Bitwise AND. In this case, checking whether the last bit in i
is set. If it is, it must be an odd number since the last bit represents 1 and all other bits represent even numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With