Results of comparing integers in C -


if x , y both int, x-y < 0 return same result x < y?

no. if x-y causes overflow or underflow, behavior undefined (because int signed type).

for example int_min - 1 < 0 undefined behavior, whereas int_min < 1 defined (and true).

when there's no overflow, 2 expressions, x-y < 0 , x < y same.

because compiled code may whatever likes when there's undefined behavior, c compiler allowed rewrite x-y < 0 x < y if wishes. isn't true if x , y unsigned types, overflow well-defined, , x-y < 0 , x < y not equivalent.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -