So new to C++ data types and I observed something really weird that I couldn't find answer on the Internet:
std::set<unsigned long> test;
test.insert(7788994347298743234);
test.insert(0113);
std::set<unsigned long>::iterator it;
for(it = test.begin(); it != test.end(); it++) {
std::cout << *it << std::endl;
}
The output:
75
7788994347298743234
This is a set with "unsigned long int" as element type, which has the range of 0 to 4,294,967,295. Now why does:
A large number like 7788994347298743234 still fits the set just fine and gets printed out? What is C++'s behavior when you try to insert some data that overflows the range of the specified type of the container? It doesn't reject and return false on insertion? Underlying it's using more memory than 32 bit to store that data though?
Any number started as leading zero is invalid? What implicit type conversion has been done to make 0113 become 75?
I ask these because what if my set needs to store elements that could have arbitrary leading zero, say, a result of CRC32 Hash (well just throwing example here, don't know if this actually applicable...)? Thanks!