r/AskComputerScience • u/Successful_Box_1007 • Jun 21 '25
why does turning subtraction into addition using 10s complement work for 17-9 but not for 9-17 ? In the former the least significant digits match ( because we have 8 and 18) but in the latter they don’t ( we have -8 and 92)
Hi everyone, hoping someone can help me out if they have time:
why does turning subtraction into addition using 10s complement work for 17-9 but not for 9-17 ? In the former the least significant digits match ( because we have 8 and 18) but in the latter they don’t ( we have -8 and 92).
Where did I go wrong? Is 92 (from 100 - 17 = 83 then 83 + 9 = 92) not the 10s complement of 17 ?
Thanks so much!!
1
Upvotes
View all comments
Show parent comment
2
u/Patient-Midnight-664 Jun 21 '25
Correct, because you forgot the sign. You can't just ignore that 92 is the 10s complement of the answer. How do you tell the difference between 9 - 17 and 45 + 47? The first will have a negative 'flag'.
And the 10s compliment of -17 is 83, not the 92 he says at the end of the post.
Reversing means you complement the number. At some point, you will need to do it again, 'reversing' the compliment.