I have the following string: “3.39112632978e+001” which I need to convert to float. WolframAlpha says that the result of this value is 33.9112632978 which evidently I should get somehow and I couldn’t figure out how.
Single.Parse("3.39112632978e+001") gives 3.39112624E+12
Double.Parse("3.39112632978e+001") gives 3391126329780.0
float.Parse("3.39112632978e+001") gives 3.39112624E+12
What should I do?
You are experiencing a localization issue wherein the
.is being interpreted as a thousands separator instead of as a decimal separator. Are you in, say, Europe?Try this:
Output:
Note that if we replace the
.by a,then we see the behavior that you are experiencing:Output:
This supports my belief that you are experiencing a localization issue.