1

I have this string: "7.0000000000000007E-2" (data.InnerText). I use the following code but this gave me the error: "Input string was not in a correct format.".

decimal value = Decimal.Parse(data.InnerText, CultureInfo.InvariantCulture);

I only need the number rounded on 2 decimals.

2
  • It might help to tag this with language. Commented Jun 14, 2013 at 11:07
  • This is C#, I suppose, changed the tag. Commented Jun 14, 2013 at 11:28

1 Answer 1

2

If your culture uses . as the decimal separator :

double d = double.Parse("7.0000000000000007E-02");

Or try that way :

decimal d = Decimal.Parse("7.0000000000000007E-02", System.Globalization.NumberStyles.Float);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.