a bug for int and long type in C++
Do you know the output of the following program? Try. #include <stdio.h> int main() { int i1,i2; long l1; i1 = 10; i2 = 599999999; l1 = i1*i2; printf(” a=%d,b=%d, axb=%ld\n”, i1,i2,l1); l1 = (long) i1*i2; printf(” a=%d,b=%d, axb=%ld\n”, i1,i2,l1); return 0; } The answer is: On 32bits system, a=10,b=599999999, axb=1705032694 a=10,b=599999999… (阅读全文)
