3 ms·
if( x > INT_MAX - n ) // overflow for x + n Your definition of a far more complicated dance is absurd. Signed integer being undefined makes a lot of integer m
by atiedebee 2y ago
if( x > INT_MAX - n ) // overflow for x + n
Your definition of a far more complicated dance is absurd.
Signed integer being undefined makes a lot of integer math faster actually: https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html?m=1 https://kristerw.blogspot.com/2016/02/how-undefined-signed-o...
There's a reason zig made unsigned overflow undefined: it allows for more optimisations (Zig can also afford it thanks to their wrapping addition (+%) operator).