I have two decimals:
var first = 1.567m;
var second = 1.568m;
var areEqual = first == second; // false
And I have an acceptable margin of error; which is 0.010
.
So what I need is a Check method:
Check(first: 1.567m, second: 1.577m, margin: 0.010m); // true
Check(first: 1.567m, second: 1.578m, margin: 0.010m); // false
Check(first: 1.567m, second: 1.578m, margin: 0.011m); // true
How can I write that?
if (Math.Abs(first - second) <= margin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With