If there is 11 bit two's complement number with a range of -1024 to 1023, what happens if we go outside that range? For example, I have -1024 and I subtract 1. Or I have 1023 and I add 1. Does it crash? Stay unchanged? Change to different number?
Asked
Active
Viewed 250 times
1 Answers
0
-1025 cannot be represented by an 11-bit two’s complement number. If we add them, there's an overflow:
-1024 = 10000000000 => 11 bits
-1 = +11111111111 => 11 bits
------------
101111111111 => 12 bits
What happens next depends on your implementation. As this is a question of fixed-width binary numbers, we drop the overflow bit, leaving us with 01111111111
or 1023
.
There are many similar questions on Stack Overflow that you may want to look at.

Ross Jacobs
- 2,962
- 1
- 17
- 27