4 ms·
Someone needs to explain to Teddy how the compiler implements subtraction. Hint: his example is fine (and thus, Ted is wrong). But, since Ted is OpenBSD.. her
by gonzo 12y ago
Someone needs to explain to Teddy how the compiler implements subtraction.
Hint: his example is fine (and thus, Ted is wrong).
But, since Ted is OpenBSD.. here come the downvotes.
As the poster below states, the example in the last link of Ted's posting has overflow problems.
- cremno 12y agoYou should read the post again and then open the last link. Then tell us again that the example is fine.
- imron 12y agoDoesn't seem so fine to me.. /*compare.c*/ #include <stdio.h> int compare( int x, int y ) { return x - y; } void testCompare( int x, int y ) { if ( compare( x, y ) < 0 ) { printf( "%d is less than %d\n", x, y ); } else { printf( "%d is greater than or equal to %d\n", x, y ); } } int main() { testCompare( 5, 10 ); testCompare( 10, 5 ); testCompare( 1987654321, -1987654321 ); return 0; } $ clang -o compare compare.c $ ./compare 5 is less than 10 10 is greater than or equal to 5 1987654321 is less than -1987654321