??? 06/08/04 13:08 Read: times Msg Score: -1 -1 Answer is Wrong |
#72045 - RE: Weekend Puzzle Responding to: ???'s previous message |
"I am somewhat surprised that after about 24 hours there has been only one poke at this small program."
Because the code is pure nonsense. On C all numbers not equal zero are true. So it is not determined, which values are returned by: a < b; and by: !z So looking at: z = a > b; b = (z * a + !z * b) - (z * b + !z * a); there are two cases: 1. a <= b: z = 0 then: b = xb - ya; where x = !0 and y = !0 and unknown if x, y == 1 or 2 or 0xFF or what. 2. a > b then z != 0 (again it can be 1, 2, 0xFF or what) and then: b = za - zb; which was equal meaningless. So only what I can say, its a good example of writing very bad code. ATTENTION: Never handle logical expressions in arithmetic expressions !!! The only right usage of logical expressions was in conditional expressions. So if you want to do the following, why not write it down ? b = (a > b) ? (a - b) : (b - a); Peter |