toot.wales is one of the many independent Mastodon servers you can use to participate in the fediverse.
We are the Open Social network for Wales and the Welsh, at home and abroad! Y rhwydwaith cymdeithasol annibynnol i Gymru, wedi'i bweru gan Mastodon!

Administered by:

Server stats:

657
active users

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

EDIT: ternary would work `x ? x : y`

@eniko hmm .. and what then something like 2 || 5 should give then ? 2 ? 5 ? the greater ? the smaller ? [edit] in you case to me looks like a = Max( b,c );

@gilesgoat 2, because any non-zero value is truthy so the right hand side isn't evaluated

Giles Goat

@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