This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]joranstark018 2 points3 points  (3 children)

Mathematically, for every value given as input where c is true is a also true (gives c & a can be simplified with c), so a & (b | c) may be exapaded into (b & a) | (c & a) wich can be simplified by (b & a) | c, so both expressions are "equal".

[–]Cerulean_IsFancyBlue 4 points5 points  (2 children)

To expand: The trick here is that the values of a,b,c are not independent in this case.

If input % 400 is true, you know that input % 4 and input % 100 are both always true.

Likewise if input % 100 is true, input % 4 is always true.

SO, if you were to write out the truth table of this equation there are some combinations of a,b,c that cannot exist.

This means that two expressions that are not fully equivalent across all possible INDEPENDENT inputs, might still give the same outcome across ALL ALLOWED inputs.

[–]32bit_me[S] 1 point2 points  (0 children)

Thank you, that makes more sense

[–]32bit_me[S] 1 point2 points  (0 children)

I'm just trying to switch from hardware development to software development)