#include <iostream>
#include <vector>
using std::cout;
using std::vector;
using std::endl;
int main() {
vector<double> homework;
homework.push_back(5.6);
vector<double>::size_type size;
size = homework.size();
cout << size - 800 << endl;
}
Output:
$ ./a.out
18446744073709550817
I understand that signed integer (and the overall result) is getting converted to unsigned and the resulting negative result is producing a positive result due to underflow.
Q: Why has this been implemented to behave this way ? Why can't I get the right answer here, which is -799