I dont suppose there's any way to do logical and/or in C without coercing the result to 0 or 1?
I.e. `0 || 5` would result in 5, not 1
I dont suppose there's any way to do logical and/or in C without coercing the result to 0 or 1?
I.e. `0 || 5` would result in 5, not 1
@eniko hmm .. and what then something like 2 || 5 should give then ? 2 ? 5 ? the greater ? the smaller ?
@gilesgoat 2, because any non-zero value is truthy so the right hand side isn't evaluated
@eniko That's quite a weird problem to be solved in C .. if you really want the left-to-right precedence and AVOID the computation of the 'right side' if left is already seen as 'false' .. actually I don't even know if it can be solved because it would be something 'at compile time' ? 🤔
@gilesgoat @eniko
(x = 2) ? x : 5
avoids evaluating 2 twice, but needs a variable declaration