De Morgan's Law
boolean-logic, demorgans-law, java
Solution
Does x!=0 simplify to x>0?
No that's not true. Because integers are signed.
How to simplify : `!(x!=0 || y !=0)` ?
Consider this rules :
(second De Morgan's laws )
By 1., it implies
`!(x!=0 || y !=0) <=> (!(x!=0)) && (!(y != 0))`
By 2., it implies
`(!(x!=0)) && (!(y != 0)) <=> (x == 0) && (y == 0)`
To test you can write the following loop :
for(int x = -5; x < 5; x++){
for(int y = -5; y < 5; y++){
if(!(x!=0 || y !=0))
System.out.println("True : ("+x+","+y+")");
}
}
Problem
I am trying to simplify the following using DeMorgan's Law: ! (x!=0 || y !=0) Does x!=0 simplify to x>0? Or am I wrong in the following: ``` !(x>0 || y>0) !(x>0) && !(y>0) ((x<=0) && (y<=0)) ``` Thanks.