Hacker News new | ask | show | jobs
by eesmith 2663 days ago
Max 32-bit signed int is (1<<31)-1 . Twice that is 1<<32-2.

Max 32-bit unsigned int is (1<<32)-1.

Therefore, if 'low' and 'high' are non-negative 32-bit signed integers, it is impossible for their sum, when the values are first cast to 32-bit unsigned integers, to produce a carry.

1 comments

True. I had thought low and high could be unsigned originally, in which case casting to unsigned is redundant, then the sum would produce a carry.