...
It is important to note that the above code is only compliant on systems where long long
is atleast twice the size of int
. On systems where this does not hold the following compliant solution may be used to ensure signed overflow does not occur.
...