To swap to integers, A and B, this seems to work in C,
A = A + B - ( B = A);
Why does this work? And if this works in all conditions, can this be used to shorten any other commonly implemented algorithms?
Actually it invokes undefined behaviour according to standards-
C99 §6.5: “2. Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.”
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With