std::map question

In this short program, the output is:
zero
one
unknown
two
unknown
four
five

and I wonder why.
Can anyone please let me know why 0x10 and 2 are not treated the same? Is it because they are treated as different data types? The map itself contains 6 elements, just as I would expect.

Thanks,
Richard

#include <map>
#include <string>
#include <iostream>

typedef std::map<int, std::string> INT2STRING;

INT2STRING s_enumIntToStringMap;
std::string s_unknown("unknown");

const std::string& mapIntToString( int i )
{
INT2STRING::const_iterator f = s_enumIntToStringMap.find( i );
if(f != s_enumIntToStringMap.end())
{
return (*f).second;
}// if ...

else
{
return s_unknown;
}// else
}// mapRestartModesToString()

int main(int argc, char* argv[])
{
s_enumIntToStringMap.insert(INT2STRING::value_type(0x00, "zero"));
s_enumIntToStringMap.insert(INT2STRING::value_type(0x01, "one"));
s_enumIntToStringMap.insert(INT2STRING::value_type(0x10, "two"));
s_enumIntToStringMap.insert(INT2STRING::value_type(0x11, "three"));
s_enumIntToStringMap.insert(INT2STRING::value_type(4, "four"));
s_enumIntToStringMap.insert(INT2STRING::value_type(5, "five"));

std::cout << mapIntToString( 0 ) << std::endl;
std::cout << mapIntToString( 1 ) << std::endl;
std::cout << mapIntToString( 2 ) << std::endl;
std::cout << mapIntToString( 0x10 ) << std::endl;
std::cout << mapIntToString( 3 ) << std::endl;
std::cout << mapIntToString( 4 ) << std::endl;
std::cout << mapIntToString( 5 ) << std::endl;

return 0;
}
[1873 byte] By [Richard.J] at [2007-11-18 20:27:33]
# 1 Re: std::map question
Hum, 0x10 is a hexadecimal notation, not a binary one. So 0x10 means 1 * 16 + 0 = 16.
Yves M at 2007-11-9 0:33:24 >
# 2 Re: std::map question
Thanks! I was so stuck that I did not realize it. I would have sworn it was binary ;-)
Richard.J at 2007-11-9 0:34:28 >