protected bool IsEqual(decimal x, decimal y, decimal tolerance, SideTolerance side) { //quick check if (x == y) { return(true); } //Stop checks if tolerance is set to 0 if (tolerance == 0) { return(false); } //include some math[Time consumming] (Tolerance needed to validate) if (Math.Abs(x - y) <= Math.Abs(tolerance)) { switch (side) { case SideTolerance.Both: return(true); case SideTolerance.More: return(x <= y); case SideTolerance.Less: return(x >= y); default: throw new ArgumentOutOfRangeException(); } } return(false); }
public NumericPercentageTolerance(decimal value, SideTolerance side) : base(value, side) { Value = value; valueString = (100 * value).ToString(NumberFormatInfo.InvariantInfo); switch (side) { case SideTolerance.Both: break; case SideTolerance.More: valueString = string.Format("+{0}", valueString); break; case SideTolerance.Less: valueString = string.Format("-{0}", valueString); break; default: break; } }
internal ComparerResult Compare(object x, object y, decimal tolerance, SideTolerance side) { return(base.Compare(x, y, new NumericAbsoluteTolerance(tolerance, side))); }
public NumericAbsoluteTolerance(decimal value, SideTolerance side) : base(value, side) { Value = value; }
public NumericTolerance(decimal value, SideTolerance side) : base(value.ToString(NumberFormatInfo.InvariantInfo)) { Side = side; Value = value; }
protected Tolerance(string value, SideTolerance side) { ValueString = value; this.Side = side; }
public NumericTolerance(decimal value, SideTolerance side) : base(value.ToString(NumberFormatInfo.InvariantInfo), side) { Value = value; }
internal ComparerResult Compare(object x, object y, decimal tolerance, SideTolerance side) { return base.Compare(x, y, new NumericAbsoluteTolerance(tolerance, side)); }
protected bool IsEqual(decimal x, decimal y, decimal tolerance, SideTolerance side) { //quick check if (x == y) return true; //Stop checks if tolerance is set to 0 if (tolerance == 0) return false; //include some math[Time consumming] (Tolerance needed to validate) if (Math.Abs(x - y) <= Math.Abs(tolerance)) { switch (side) { case SideTolerance.Both: return true; case SideTolerance.More: return (x <= y); case SideTolerance.Less: return (x >= y); default: throw new ArgumentOutOfRangeException(); } } return false; }