X
XjAcKs
Hi everyone. My source code is the following in VS2005:
--------
static void Main(string[] args)
{
int num = 3600;
Single XNT = 0.3F;
Single SX = 1546.08594F;
Single result = (XNT * num) / SX;
Single result2 = System.Convert.ToSingle(XNT * num) / SX;
System.Console.WriteLine(result);
System.Console.WriteLine(result2);
return;
}
--------
The result is "0.6985382", but the result2 is "0.6985381".
Why there are two diffrent result here?
When "XNT * num", because "XNT" is the type of Single, I think the system should
automatic convert the result to Single. But when I manually add the
"System.Convert.ToSingle()", the diffrent result appeared. Any idea?
Thank you!
--------
static void Main(string[] args)
{
int num = 3600;
Single XNT = 0.3F;
Single SX = 1546.08594F;
Single result = (XNT * num) / SX;
Single result2 = System.Convert.ToSingle(XNT * num) / SX;
System.Console.WriteLine(result);
System.Console.WriteLine(result2);
return;
}
--------
The result is "0.6985382", but the result2 is "0.6985381".
Why there are two diffrent result here?
When "XNT * num", because "XNT" is the type of Single, I think the system should
automatic convert the result to Single. But when I manually add the
"System.Convert.ToSingle()", the diffrent result appeared. Any idea?
Thank you!