Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The analogy between logical AND and multiplication, and logical OR and addition is called Boolean Algebra, and it's very well known.

The analogy is that when you set 1 to true and 0 to false, 1 becomes the identity for AND, and 0 becomes the identity for OR. Just as 1 is the identity for multiplication and 0 is the identity for addition.

X * 0 = 0 | X ^ F = F

X * 1 = X | X ^ T = X

X + 0 = X | X V F = X

X + 1 = ? | X V T = T <-- This one breaks the analogy

With this, you can turn any logical expression into something that looks and feels like normal algebra, with the only weird exception being that both operators distribute over each other:

A * (B + C) = A*B + A*C

A + (B * C) = (A + B) * (A + C)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: