how many unique states of information can be stored in a 16 bit piece of data.
overflow is common occurrence in binary arithmetic,Using 3 bits of two’s complement,provide an example when overflow would ocuur.
Expert Answer
Let us try to understand. For example, using 1 bit , there are 2^1 i.e just 2 states. They are 0 and 1.
using 2 bits , there are 2^2 i.e 4 states ie. 00 , 01, 10 ,11
using 3 bits there are 2^3 i.e 8 states i.e 000, 001,010, 011, 100, 101, 110 , 111
Likewise using n bits we get 2^n different states. Therefore with 16 bits we get 2^16 = 65536 states
========
Using 2’s complement, overflow occurs
1. when adding 2 positive number , the result is -ve
2. when adding 2 negative numbers, the result is +ve
Example using 3 bits for signed bits, 1 bits is for sign and remaining 2 bits for numeric part, lets add 2 and 3
2 in 3 bit binary is 010
3 in binary form is 011
now adding 010 + 011
we get 101 . Since the first bit is used to represent sign in 3 bit format, the result is -ve the answer is – 1.
When using n bits for representing signed numbers, we use 1st bit for sign and rest for numeric value. The above example show that when overflow occurs sign bit is set and the result of 2 +ve numbers became -ve