P
Peter Ammon
Howdy,
I have four unsigned long longs a, b, c, d. I want to determine whether
a+b or c+d is larger, as if there were no overflow. That is, ULLONG_MAX
+ 5 should be considered larger than 10 + 20.
The best approach I have thought of so far is to check for overflow in
both sums; if exactly one overflows, that one is larger. Otherwise,
compare the sums normally. Is there a better way?
Thanks for any ideas!
-Peter
I have four unsigned long longs a, b, c, d. I want to determine whether
a+b or c+d is larger, as if there were no overflow. That is, ULLONG_MAX
+ 5 should be considered larger than 10 + 20.
The best approach I have thought of so far is to check for overflow in
both sums; if exactly one overflows, that one is larger. Otherwise,
compare the sums normally. Is there a better way?
Thanks for any ideas!
-Peter