与逻辑运算符的表达式 - 它相当于什么?

时间:2016-11-13 17:03:07

标签: java logical-operators boolean-algebra

我有这个逻辑运算符表达式:

!(!(a != b) && (b > 7))

如何简化并找到相应的内容?

2 个答案:

答案 0 :(得分:2)

使用Demorgan's Laws

!(!(a != b) && (b > 7))
!!(a != b) || !(b > 7)
a != b || b <= 7

答案 1 :(得分:0)

正如其他人所说:Demorgan's Laws

!(!(a != b) && (b > 7)) // x != y --> !(x == y) 
!(!!(a == b) && (b > 7)) // !!x --> x 
!((a == b) && (b > 7)) // !(x && y) --> !x || !y
!(a == b) || !(b > 7) // !(x == y) --> x != y;; !(x > y) --> x <= y
(a != b) || (b <= 7)