I'd like to make sure I have a solid implementation for equality, greater than, less than, less than or equal to, and greater than or equal to.
You are using binary floating point arithmetic.
Binary floating point arithmetic was designed to represent physical quantities like length, mass, charge, time, and so on.
Presumably then you are using binary floating point arithmetic as it was intended to be used: to do arithmetic on physical quantities.
Measurements of physical quantities always have a particular precision, depending on the precision of the device used to measure them.
Since you are the one providing the values for the quantities you are manipulating, you are the one who knows what the "error bars" are on that quantity. For example, if you are providing the quantity "the height of the building is 123.56 metres" then you know that this is accurate to the centimetre, but not to the micrometer.
Therefore, when comparing two quantities for equality, the desired semantics is to say "are these two quantities equal within the error bars specified by each measurement?"
So now we have an answer to your question. What you must do is keep track of what the error is on each quantity; for example, the height of the building is "within 0.01 of 123.56 meters" because you know that is how precise the measurement is. If you then get another measurement which is 123.5587 and want to know whether the two measurements are "equal" within error tolerances, then do the subtraction and see if it falls into the error tolerance. In this case it does. If the measurements were in fact precise to the micrometre, then they are not equal.
In short: you are the only person here who knows what sensible error tolerances are, because you are the only person who knows where the figures you are manipulating came from in the first place. Use whatever error tolerance makes sense for your measurements given the precision of the equipment you used to produce it.
Represents the smallest positive Double value that is greater than zero.
See msdn.microsoft.com/en-us/library/…. – Hypogeous