Sunday, May 19, 2013

Binary Over Flow


Maths in a processor is normally performed using set numbers of bits. For example where you add 8 bits to 8 bits. This will often cause no problems at all:
 00110011 (51)
+00001010 (10)
 --------
 00111101 (61)
But what happens if we add the following numbers together:
 01110011 (115)
+01001010 (74)
 --------
 10111101 (189)
This may appear to have gone ok, but we have a problem. If we are dealing with twos complement numbers the answer from adding two positive numbers together is negative!
 01110011 (115)
+01001010 (74)
 --------
 10111101 (-67!)

No comments:

Post a Comment