Two's Complement Subtraction

written by Crystal Barchet and Teresa Carrigan


Run model in your browser


Top

THINGS TO NOTICE

When two numbers of the same sign are subtracted, it is impossible to get an overflow error.

If you add two numbers that have the same bit in the left-most column, and the result has a different bit in that column, there is always an overflow error. This is a different way to detect overflow.

No borrows are needed, ever!

Top

THINGS TO TRY

Set the slow-motion to about .50 seconds (or slower) and press the step button a few times. Watch the demonstration of each step.

Do each step by hand, then press step to check your work.

Press setup until you see a problem that you think will cause an overflow error. Press run to see if it does overflow.


Home

Applets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.