Comments on Leap Year Test in K&R

Post Comment

Thaumasiotes said:

For those who were curious why these could both work, note that (A && B) || C differs from A && (B || C) in two cases: when A is false, C is true, and B is any value.

But in this case in particular, those differences would create a bug when A is false (the year is not divisible by 4) at the same time that C is true (the year is divisible by 400). Since that can't happen, the bug cannot occur.

01 Mar 2020 22:30 GMT (#1 of 1 comment)
Post Comment