On Fri, 10 Apr 2015 01:34 am, Chris Angelico wrote:
> It's equally impossible for the addition of two positive signed
> integers to result in a negative integer.
Why oh why do C programmers tell such porkies??? *semi-wink*
[steve@ando c]$ gcc add.c
[steve@ando c]$ ./a.out
a = 1
b = 2147483647
a+b = -2147483648
Looks like a negative integer to me, but then, given that its undefined
behaviour, perhaps the compiler flipped some pixels on the screen so it
merely *looks* negative.
Here's the source code:
[steve@ando c]$ cat add.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int a;
a = 1;
int b;
b = 2147483647;
printf("a = %d\n", a);
printf("b = %d\n", b);
printf("a+b = %d\n", a+b);
return 0;
}
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list