I was looking through Expert C Programming by Peter Van Der Linden recently and came across this use for the += operator:
“If you have a complicated array reference and you want to demonstrate that the same index is used for both references, then:
node[i >> 3] += ~(0x01 << (i & 0x7));
is the way to go.”
As much as I’ve tried, I can’t figure out this code. I’m hoping someone here can explain what is actually going on and why it can be used to demonstrate that the same index is used?
My interpretation of the quote is that
is preferable to
since it’s easier to see at a glance what the intent is.
More so if
STUFFis also complicated, since this makes the overall expression even harder to parse at a glance.In the book, van der Linden explains where the code he shows came from: