While formatting a float number, I get an unexpected result.
For example writing any of this
float argument = 40.432;
char buff[100];
snprintf(buff, sizeof(buff), "%f", argument);
std::string result = buff;
or
std::string result = boost::str(boost::format("%" + "f")%argument);
the value of result is 40.431999, while if I set the value of argument 40.111 instead of 40.432 , the result will be 40.111000, as it is accepted. And if I set the value of argument 40.4, the result will be 40.400002.
Now I understand why it is so, and my question is how can I get 40.432000 as a result?