Hacker News new | ask | show | jobs
by lostmsu 2333 days ago
I love the explanation, but why did the guy suggest a complicated bit work instead of just doing sum += arr[i] > 128 ? arr[i] : 0 is beyond me.
2 comments

That would not evoke the behavior he wanted to call attention to.
Theres still a conditional branch in that statement
That depends on the compiler, and I'd expect most to optimize this into a cmov