A couple of days ago there was a thread "Returning the machine epsilon".
The responses in that thread suggested using Double.Epsilon or
Single.Epsilon. Since both these seem to return zero I thought I would try
to compute these epsilons myself. Using the following program fragment:
===================================
private void button4_Click(object sender, System.EventArgs e) {
float a;
float f= 1.0f;
float one= 1.0f;
do {
f/= 2.0f;
a= one+f;
} while (a>one);
Say("f="+FNum(f));
} // button4_Click
public static string FNum(float x){
return x.ToString("n20");
} // FNum
public static void Say(string x) {
MessageBox.Show(x);
} // Say
===================================
If I run this using Debug|Start I get:
f=0.00000005960464000000
which is probably the correct answer.
If I run this using Debug|Start Without Debugging I get:
f=0.00000000000000011102
which is probably Double.Epsilon.
Tiny changes to the above program fragment change this behavior.
I am using Microsoft Development Environment 2003, Version 7.1.3088 and
Microsoft .NET Framework 1.1, Version 1.1.4322 .
Any ideas?
--
Clive Tooth
http://www.clivetooth.dk