Quote:
Originally Posted by ibex333
In the first scenario, that something STILL gets done even if the answer is x or y...
|
This is incorrect: if both x and y are true, then (x or y) is still true, but not x or not y is false, so we shouldn't be doing something.
1) not x or not y - this means either x is false, or y is false, or both are false
2) not (x and y) - this means it's not true that both x and y are true
If it isn't obvious to you that these say the same thing, then I don't know, perhaps just work out via truth tables and accept it as a fact.
Quote:
Originally Posted by ibex333
As long as the answer is not x OR not y, do something. this is the same as saying as long as the answer is not( x and y ) do something... But than again, who negated the OR to AND? We only negated not x, not y!
|
Fixed it for you. OR gets negated to AND when you pull not out, the above gives the common sense reason, and if you don't agree, then simply accept De Morgan's laws as rules of logic, which can be proven via truth tables to be identical
Look at your code: your condition can never be false, it's always true. In order for it to be false, natBornCitizen would have to be equal to 'Y', 'y', Yes' ..., all those at the same time, which it clearly can't be. E.g. if natBornCitizen is 'Y', then it's not equal to 'y', so the second statement is true, and since you're OR-ing, the whole condition is true. You're always alerting.
The correct code is false if all those are true, so natBornCitizen is not equal to any of those, which is probably the intended meaning.