T
TisMe
Hi All,
The code below works as expected, returning 0.2857143
public partial class tests : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Single myVal = (float)200.00 / (float)700.00;
this.Label1.Text = myVal.ToString();
}
}
How ever, if I change the 200.00 to 200 and the 700.00 to 700, the
result is 0.
Can anyone tell me why this happens? Surely dividing a float by a
float should return a float? I can easily change the values in my
simple example, but how would I fix this problem in my application?
e.g. How do I change a variables value from 200 to 200.00?
Thank you!
The code below works as expected, returning 0.2857143
public partial class tests : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Single myVal = (float)200.00 / (float)700.00;
this.Label1.Text = myVal.ToString();
}
}
How ever, if I change the 200.00 to 200 and the 700.00 to 700, the
result is 0.
Can anyone tell me why this happens? Surely dividing a float by a
float should return a float? I can easily change the values in my
simple example, but how would I fix this problem in my application?
e.g. How do I change a variables value from 200 to 200.00?
Thank you!