In C#, is it possible to perform a sum of two 32-bit integers without using things like if..else, loops etc?
That is, can it be done using only the bitwise operations OR (|), AND (&), XOR (^), NOT (!), shift left (<<) and shift right (>>)?
Here is an example for your amusement
The loop could be unrolled. Number of times it executes, depends on the number of bits set in operands, but it’s never greater than the width of
unsigned int. Oncecarrybecomes0, next iterations don’t change anything.