I was learning computer architecture and decided to experiment with multiplication overflow. An overflow is observed for INT_MAX * INT_MAX
, but I am not sure why this gives the product 1 in C/C++.
#include <stdio.h>
#include <limits.h>
int main()
{
int num = INT_MAX;
printf("%0x\n", num); //stdout is 0x7fffffff
printf("%d\n", num * num); //stdout is 1
return 0;
}