T
Tony Johansson
Hello!
I writing a win form calculator but I just wonder if I can do something to
prevent to get this E notation.
For example if I enter 0.000001 on my calculator my using the Buttons that
my calculator uses as buttons I get
-1E-06 when hit the +/- button this causes problem if I add more figures
than I get -1E-06000 and this
is not valid.
Below can you see my event handler that is called when the +/- button is hit
and some of the other methods that is relevant in this example. My TextBox
field on the form is called txtDisplay.
private void btnNeg_Click(object sender, EventArgs e)
{
if (txtDisplay.Text.Length > 0)
{
SetTextValue((ParseUsingDecimalPoint()
* -1).ToString(CultureInfo.InvariantCulture));
}
}
private double ParseUsingDecimalPoint()
{
return double.Parse(txtDisplay.Text, CultureInfo.InvariantCulture);
}
private void SetTextValue(string textValue)
{
txtDisplay.Text = textValue;
}
//Tony
I writing a win form calculator but I just wonder if I can do something to
prevent to get this E notation.
For example if I enter 0.000001 on my calculator my using the Buttons that
my calculator uses as buttons I get
-1E-06 when hit the +/- button this causes problem if I add more figures
than I get -1E-06000 and this
is not valid.
Below can you see my event handler that is called when the +/- button is hit
and some of the other methods that is relevant in this example. My TextBox
field on the form is called txtDisplay.
private void btnNeg_Click(object sender, EventArgs e)
{
if (txtDisplay.Text.Length > 0)
{
SetTextValue((ParseUsingDecimalPoint()
* -1).ToString(CultureInfo.InvariantCulture));
}
}
private double ParseUsingDecimalPoint()
{
return double.Parse(txtDisplay.Text, CultureInfo.InvariantCulture);
}
private void SetTextValue(string textValue)
{
txtDisplay.Text = textValue;
}
//Tony