Can I say "it depends" ??
I'd be just as happy doing the test in-line as Sinc's Reply#12
... except use an exponent ... easy for my old brain; if the exponent is -8 thats 8 significant places, no need to count zero's .. and the test criteria is immediately transparent.
I'd like a buck for every time I've shot myself in the foot trying to be too smart.
This seems pretty transparent :-
public class FuzzyTester
{
[CommandMethod("CmdFuzz")]
static public void CmdFuzz()
{
double num1 = 10.00000001;
//double num2 = 10.00000002;
double num2 = 10.00000005;
if (Math.Abs(num1 - num2) < 1.0e-8)
{
MessageBox.Show("Bingo !", "My Fuzzy Interpreter",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Pffffft !", "My Fuzzy Interpreter",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
Bryco, Just a note on this ;
bool B=false;
You do not need to initialise the Value to false.
The process of declaring the variable
ie:
bool B;
will initialise the variable to false by default.
Similarly ;
int num;
will initialise num to 0 [zero]
Have a good weekend