Converting strings to float seems not to work correctly

I spend many hours with this problem, there are already many topics about converting types in here and in unityanswers. None seems to cover the problem. Converting strings to float seems not to work correctly, not sure if this is a bug or I’m missing something. Basically what happens is values getting rounded when converting from string to float. I used the new float to feed a TextMesh but it’s also bad in the Debug.Log. (BTW I’m using this for iPhone)

Examples:
Parsing string 108,952.584 to float results in: 108952.6
Parsing string 7,718.320 to float results in: 7718.32

corrected Code example:

void DoSomething() 
{	
	string StringFormattedValue;
Double bestScoreWorld;

		bestScoreWorld = Double.Parse( StringFormattedValue );

		//Double.TryParse( StringFormattedValue, out bestScoreWorld );//alternatively use this

		Debug.Log( bestScoreWorld );
}
}

There is two things you need to take into account here.

First of all, print statements often remove trailing 0s after the decimal mark from a float, which is likely what happens with your second example. If you want to force your print statement to display a certain number of digits, you can use the ToString function:
Debug.Log("StaticVariables.bestScoreWorld "+ StaticVariables.bestScoreWorld[B].ToString("F4")[/B]);
(this shows 4 digits after the decimal mark, replace the 4 by any other number to show more or less). Note that mathematically speaking, 7,718.320 and 7718.32 are completely equal. Any real number has infinite trailing zeros after the decimal mark, so it’s a sane convention to remove them ;).

Second, floating point numbers have limited precision. In general you cannot count on a float to be accurate for more than 7 digits (http://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding), which is likely why your first number is off.

If you really need such high precision, you could try using doubles instead of floats. Doubles have similar limitations, but with higher precision.

Thanks tomvds :-)! Using the wrong type was the problem. I agree with everything you say and trying Double.Parse() again with correct variable type solved it! So setting variables from float to Type Double is required in addition;-).