I have declared two int variables: n1=2147483647
(the maximum value for my compiler), and n2=-2147453648
(the minimum value). The results of n1*n1
and n2*n2
are surprisingly 1 and 0.
Why these values? If it is related to the range of the data type, then could it not be any value, or the largest value an int can hold?
int main()
{
int n1 = 2147483647;
cout << "Product is : " << n1 * n1 << endl;
int n2 = -2147483648;
cout << "Product is : " << n2 * n2 << endl;
return 0;
}