Why you don't get the third number
std::atof
will take as many characters as it can that represent a decimal number. That's 4.6
. The next dot cannot be part of the number, because there is no such thing as a decimal number with two dots. Decimal numbers only have one dot, separating the integer and the fractional parts.
Why you get 4.59999990 instead of 4.6
Because floating point numbers cannot store any possible combination of integer and fractional part. They have limited space to store information, so they always are just approximations. See is floating point math broken?.
How to get the version
A version is not a number. That version consists of three numbers, not one: 4
, 6
and 0
. They are integers, not decimal numbers. So you need to either just handle the version as a string:
if (strVersion == "4.6.0")
or you have to split it into three parts and get those integer values separately. See Splitting a C++ std::string using tokens for how to do that.