What is this boolean algebra expression inverted?

265 Views Asked by At

I basically have this boolean algebra expression:

((xDir === 1 || xDir === -1) &&
 (yDir === 1 || yDir === -1))

What is the "inverse" of this? I tried using DeMorgan's thereoms but I don't think I did it properly. I ended up with something like:

(!(xDir === 1 && xDir === -1) &&
 !(yDir === 1 && yDir === -1))

What is the inverse equation?

1

There are 1 best solutions below

2
On BEST ANSWER

Using the programmatic notation,

!((a || b) && (c || d)) -> !(a || b) || !(c || d) -> (!a && !b) || (!c && !d)

There is no real benefit of effecting this transform as the final expression is more complex to evaluate and less readable.