0

Identity low of logic

Good day, I need help with some boolean algebra. I don't really know much, and my friends are having a hard time. If someone can help, here's the question thing. Identity low of logic: A || (A && B) =A

17th Mar 2020, 9:35 PM
SomeoneCurly
7 Answers
+ 2
The bracket part comes first A&&B which is B then we have A||B which will give you A, because the || only check for the first occurrence of true value
17th Mar 2020, 9:40 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Btw.: These things differ between languages. It's one of the things you can look up whenever you're not sure. The keyword for regoogling it every time or printing it out as a cheat sheet once is: operator precedence!
17th Mar 2020, 10:34 PM
HonFu
HonFu - avatar
+ 2
~ swim ~, the basic logic of && and || may be the same, but in the details there are a lot of differences when it comes to writing actual conditions and they get a bit longer. Just compare the two lists of what is evaluated when and in which direction for C and Python ... it's tricky, to say the least. https://docs.python.org/3/reference/expressions.html https://en.cppreference.com/w/c/language/operator_precedence
17th Mar 2020, 10:52 PM
HonFu
HonFu - avatar
+ 2
~ swim ~, đŸ€Ł. You're right, there's short circuit in Python as well, so as I said, if you only look at && and ||, behaviour is the same. However, only look at not/!, and suddenly things start to change. And beyond that, it doesn't get less slippery.
17th Mar 2020, 11:04 PM
HonFu
HonFu - avatar