I tried comparing two INT_MAX and then comparing result of this with a integer and I'm getting this weird result.Could u please explain why this is happening?
#include <iostream>
#include <climits>
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int a = 2;
int option1 = min(INT_MAX, 1+INT_MAX);
cout << "Result 1 " << option1 << endl;
cout << "Result 2" << min(option1, 1+a);
return 0;
}
It's giving this output:
Output:
Result 1 -2147483648
Result 2-2147483648
According to me result 2 should be 3 but it's giving something else.I'm not getting the reason behind this different output.