if (Equation == "." || Equation == "")
Answer = double.NaN;
else
Answer = (double)Equation.EvalNumerical();
PreviousAnswerFlag = true;
Equation = "";
Answer = double.Parse(Answer.ToString("G7", CultureInfo.InvariantCulture));
OutputBox.Content = Answer;
I am building a calculator using WPF and because there is a set size to the window, the box used to output the answer cuts it off at a specific point (Around 9 numbers excluding negative and decimal symbols). Currently I am using a NuGet package to parse the Equation in string form into an answer and am using .ToString()
to convert the number into its exponent but this happens at around 14 digits and cuts off when the answer goes above 999,999,999.
I need something that will convert the number to exponential form after nine digits or something that will round the number to 9 digits that counts zeros (as Math.Round ()
does significant figures, the number is not always 9 digits long because it doesn't count initial zeros). I also need this to work regardless or positive, negative or decimal.