boolean - Comparing not then and vs and then not -
i'm wondering if there's difference between if or while statement if status either (!a && !b) (let's phone call statement 1) or !(a && b) (let's phone call statement 2).
i thinking it, , have 4 combinations of , b possible, , think status different if a != b. i'm hoping can check logic.
if , b both true, statements 1 , 2 both false. if , b both false, statements 1 , 2 both true. ?however, if true , b false, or inverse, statement 1 false, statement 2 true. correct?
you asking fundamental law of boolean algebra: de morgan's laws useful know when re-working or simplifying conditionals.
de morgan's laws!(a && b) = (!a || !b) !(a || b) = (!a && !b) your intuition statements 1 , 2 might not equivalent correct. working through 4 possibilities of a , b above shows actual equivalencies given de morgan's laws.
key: ∧ logical , (&&); ∨ logical or (||).
image source: http://ndp.jct.ac.il/tutorials/mavomath/node15.html
boolean boolean-logic boolean-operations
No comments:
Post a Comment