Multiplying char and int together in C part 2
- by teehoo
If I do the following:
int c0 = CHAR_MAX; //8 bit
int c1 = CHAR_MAX; //8-bit
int i = c0*c1; //store in 32-bit variable
printf("%d\n", i); //prints 16129
We can see that there is no problem with to 8-bit numbers being multiplied together, and producing a 32-bit output.
However, if I do
int i0 = INT_MAX; //32-bit
int i1 = INT_MAX; //32 bit…