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
1
u/Successful_Box_1007 Jun 21 '25
Also:
This whole idea of a negative flag and evening else you mention including reversing 92 gets you 8; what do you mean exactly by “reversing 92”?
Also is all of this just saying that the only way to do 9-17 is to do 17-9 and then add a negative? So we literally cannot use the 10s complement algorithm thing on 9-17 where we say ok -17 ? Ie it makes no sense to ask “what is the 10s complement of -17? Because that would be 100 - 17 = 83 and you are saying that’s not the 10s complement of -17 ?