3 ms·
>> This would require keeping track of which one is bigger somewhere else unless you had enough room to store a sign. Nope. You assume the math is being done m
by phkahler 11y ago
>> This would require keeping track of which one is bigger somewhere else unless you had enough room to store a sign.
Nope. You assume the math is being done mod 2^32 or 2^64 and it just works weather you use signed or unsigned integers. Pro-tip: the hardware does the exact same bit operations for signed and unsigned addition and subtraction (except for carry/borrow which aren't part of the C standard anyway). integer overflow is undefined, but this behavior is AFAICT universal anyway. If it didn't behave this way then a difference would in fact need the extra bit.
- hamburglar 11y agoOh, excellent observation. I am wrong. :)