I have the following numbers as strings; 22570438, 22570481, 22570480.
var listOfStrings = new List<string> { "22570438", "22570481", "22570480" };
foreach (var val in listOfStrings)
{
float numTest = 0;
numTest = Convert.ToInt64(float.Parse(val));
numTest = long.Parse(val);
numTest = float.Parse(val.ToString().TrimStart().TrimEnd(), CultureInfo.InvariantCulture.NumberFormat);
}
For number, 22570438, in these 3 instances the number returned is 22570438, as with 22570480 But for 22570481, these 3 instances return 22570480. Code below is a sample how I'm doing the testing and not an code issue. I have tried it in other projects and still getting same result.
Has anyone experience this issue and is it a compiler issue when converting 22570481 to a float ??
I tried finding similar questions but If anyone knows a post that could help please reply with link.