r/AskComputerScience • • Aug 26 '25

Adding with 2s complement

I'm learning to add with 2s complement, and I think I have it down for the most part but there's something still tripping me up. I'm using 6-bits.

When I add -25 and -8, I get
1011111 which seems correct as is and has a leading 1 to show negative, but overflows my 6 bits

When I add +25 and -8, I get
011001 for 25 and for 8 I have 001000, flip and add 1 for 110111 into 111000

Then when I add 011001 and 111000 I get 1010001 instead of the expected 010001. Why does the overflow on this one make it a different number? Why does it not lead with a zero? Am I missing something? I feel like I'm skipping something important but don't know what

Please help, I've been looking at this and googling for an hour and haven't found an explanation

2 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/scarcelyberries Aug 29 '25

Thank you! I understood about half of this and I'll keep coming back to the comment for the rest later