I found some exercises where you combine n-bit 2’s complement values in different ways and simplify the output where possible. (Their practice exercises use 16-bit, but that’s irrelevant).
Eg:
!(!x&!y) == x|y
0 & y, negate the output == -1
I’m having no problem applying De Morgan’s laws with the examples using AND, OR, and NOT but I am having difficulty using NOT with + and –
Eg:
!(!x+y) == x-y
!(y-1) == -y
How does NOT distribute?
Edit: responding to comments: I realize this is a bitwise NOT. My question is: in algebraic terms, how does it distribute as per algebra? Example on Wikipedia
With 2’s complement numbers when you bitwise NOT them it is the same as saying the negative of the number minus 1, so
!xis equivalent to-x - 1where x can be a single variable or an expression.Starting with
!(!x+y), well!xis going to be-x - 1so then it is!(-x - 1 + y)which becomes-(-x - 1 + y) - 1which simplifies tox - y.And for
!(y-1), that becomes-(y - 1) - 1 = -y + 1 - 1 = -y.