Y
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
ncmncm
2333 days ago
That would not evoke the behavior he wanted to call attention to.
link
rabryan35
2333 days ago
Theres still a conditional branch in that statement
link
lostmsu
2333 days ago
That depends on the compiler, and I'd expect most to optimize this into a cmov
link