Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Short-circuiting in C
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Keith Thompson, post: 4214988"] Not everyone is; most of us are specifically allowing for the possibility of values other than 0 and 1. I think the OP is trying to minimize branching, not eliminate it altogether. An ideal solution to his problem would be an operator that acts like && except that it doesn't short-circuit (if C had such an operator). The branching implied by the "if" is unavoidable. Hmm. static inline int and(x, y) { return !!x & !!y; } if (and(and(a, b), c)) { /* Do stuff */ } (untested) On the other hand, the OP had said this code is running on a GPU, and he's using a specialized compiler for a language very similar to C, but not quite C. It could be that others have run into similar issue, and that the tools he's already using provide better solutions than anything we C folks can come up with. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Short-circuiting in C
Top