3 ms·
I don't get this. If c can be 0 or 1, then a can be 0 or 1, so it can be all-0s but not all-1s. b can be -1 or 0, so that part is fine. Can you show actual C or
by tom_mellior 6y ago
I don't get this. If c can be 0 or 1, then a can be 0 or 1, so it can be all-0s but not all-1s. b can be -1 or 0, so that part is fine. Can you show actual C or C++ code for a function like this:
int select(int x, int y, bool condition) {
...
}
- ncmncm 6y agoSorry, brain freeze. See https://news.ycombinator.com/item?id=23237663 https://news.ycombinator.com/item?id=23237663 The bitwise thing is correctly -c&x|(c-1)&y.
- tom_mellior 6y agoOh, yes, I should have realized that -c is enough to transform from 0/1 to 0/-1. Thanks!