Hello,
After learning about digital adder-subtractors, I thought I would play around with a simulator to confirm my understanding: (http://teahlab.com/4-bit_Adder_Subtractor/)
Unfortunately, this only made it more confusing
. While everything makes sense with sums of 0 or higher, I'm having a hard time understanding how negative numbers are represented.
Take a look at my attached screenshot, for instance. Everything in blue represents a LOW state, while everything in red represents a HIGH state; hence, the simulator is in "subtractor" mode with the "B2" input HIGH and all other inputs LOW.
Now if I'm understanding this, I should be subtracting 4 from 0, in which case the "sum" would be negative. My limited knowledge of digital arithmetic tells me that negative numbers are represented in the "2's complement" form, with the MSB representing the sign (+ or -). So:
0100 = 4
1011 = 1's compliment
1100 = 2's compliment
But reading from the top down, the simulator is outputting "0011"! Could someone please explain where my logic fails?!
Thanks,
bob800
After learning about digital adder-subtractors, I thought I would play around with a simulator to confirm my understanding: (http://teahlab.com/4-bit_Adder_Subtractor/)
Unfortunately, this only made it more confusing
Take a look at my attached screenshot, for instance. Everything in blue represents a LOW state, while everything in red represents a HIGH state; hence, the simulator is in "subtractor" mode with the "B2" input HIGH and all other inputs LOW.
Now if I'm understanding this, I should be subtracting 4 from 0, in which case the "sum" would be negative. My limited knowledge of digital arithmetic tells me that negative numbers are represented in the "2's complement" form, with the MSB representing the sign (+ or -). So:
0100 = 4
1011 = 1's compliment
1100 = 2's compliment
But reading from the top down, the simulator is outputting "0011"! Could someone please explain where my logic fails?!
Thanks,
bob800
Attachments
-
9.7 KB Views: 60