F
Fritz
If I run this on my computer exactly as typed below, 'pos2' and 'hold'
are not equal (Windows XP, AMD Athlon 64 X2 Dual, .NET 3.5, Release
Build). Both floats are computed separately, but the same way and with
the same inputs. How can this be?
class Program
{
static int minPos = 0;
static float res = Convert.ToSingle("0.004");
public static float ConvertToSlideZCoord(int stageZCoord)
{
return (stageZCoord - minPos) * res;
}
static void Main(string[] args)
{
while (true)
{
int steps = 41303;
Console.WriteLine("Steps = " + steps);
float hold = ConvertToSlideZCoord(steps);
Console.WriteLine("Steps = " + steps);
float pos2 = ConvertToSlideZCoord(steps);
if (pos2 != hold)
{
Console.WriteLine("Not equal");
Console.ReadKey();
}
}
}
}
are not equal (Windows XP, AMD Athlon 64 X2 Dual, .NET 3.5, Release
Build). Both floats are computed separately, but the same way and with
the same inputs. How can this be?
class Program
{
static int minPos = 0;
static float res = Convert.ToSingle("0.004");
public static float ConvertToSlideZCoord(int stageZCoord)
{
return (stageZCoord - minPos) * res;
}
static void Main(string[] args)
{
while (true)
{
int steps = 41303;
Console.WriteLine("Steps = " + steps);
float hold = ConvertToSlideZCoord(steps);
Console.WriteLine("Steps = " + steps);
float pos2 = ConvertToSlideZCoord(steps);
if (pos2 != hold)
{
Console.WriteLine("Not equal");
Console.ReadKey();
}
}
}
}