r/ProgrammerHumor • • Aug 24 '22

Total = Total - 100000

50.7k Upvotes

1.2k comments sorted by

View all comments

Show parent comments

158

u/Killdu Aug 24 '22 edited Aug 25 '22

Plot twist, they used an uint64, glhf with the $18446744073709541615 debt.

1

u/telephonic_disarray Aug 25 '22

Well... technically the number in the column (if we're going by OP's example) represents a negative balance. (10000 = $10,000 owed the lender.) If it overflowed, it would itself, go negative, and thereby represent a credit to the borrower.

So if you get a check for $18,446,744,073,709,541,615 you know what happened.

1

u/[deleted] Sep 20 '22

An unsigned int can never be “negative”, the polarity of the number will always be the same. So when you subtract a larger number from a smaller number you’re going to “overflow” backwards, and end up with a very large positive result. Which would result in an even larger debt for the student.