Hello. I have a problem displaying double values, it removes 0 in front. For example answer should be 0.14 and it gives me 141.37.
Calculations
Page 1 of 15 Replies - 203 Views - Last Post: 05 October 2012 - 03:27 AM
Replies To: Calculations
#2
Re: Calculations
Posted 05 October 2012 - 02:28 AM
Without seeing your code it's impossible to tell what's wrong. Sure we could throw guesses but that's not worth it.
#3
Re: Calculations
Posted 05 October 2012 - 02:32 AM
If it just cut off "0.", the result would be 14137, not 141.37, right (assuming the number in question was really 0.14137 - not just 0.14)? It looks more like the result got multiplied by 1000 somewhere.
But as Janne_panne said, it's impossible for us to tell you how that happened without seeing your code.
But as Janne_panne said, it's impossible for us to tell you how that happened without seeing your code.
#4
Re: Calculations
Posted 05 October 2012 - 03:07 AM
For example
0.6 + 0.5 i am getting 11
private void button1_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1.Text);
double y = Convert.ToDouble(textBox2.Text);
textBox3.Text = Convert.ToString(x+y);
}
0.6 + 0.5 i am getting 11
#5
Re: Calculations
Posted 05 October 2012 - 03:23 AM
So you enter 0.6 and 0.5 in textBox1 and textBox2 respectively? What's your system's locale?
Conversions to and from strings are locale-sensitive by default. If your system's locale that uses commas instead of dots as the decimal separator, you'll need to enter the numbers as 0,6 and 0,5 or you'll need to tell the conversion methods to use a different locale.
Conversions to and from strings are locale-sensitive by default. If your system's locale that uses commas instead of dots as the decimal separator, you'll need to enter the numbers as 0,6 and 0,5 or you'll need to tell the conversion methods to use a different locale.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|