You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The current implementation of e.g. Length.Equals(Length other, Length tolerance) can lead to false negatives at the boundaries of the tolerance (for instance when comparing a with a - tolerance).
To Reproduce
var tolerance = Length.FromMillimeters(0.5);
var length = Length.FromMeters(0.1);
Assert.True((length - tolerance).Equals(length, tolerance));
The assert fails, which makes sense if you rephrase it as Assert.True(((length - tolerance) - length).Abs() <= tolerance);
which also fails as ((length - tolerance) - length).Abs().Millimeters == 0.50000000000000044
due to floating-point arithmetic.
Expected behavior
That the above Assert with Equals returns true.
Additional context
Tried it with UnitsNet 4.132.0, 5.43.0 and on the current master branch (1b3647f).
The text was updated successfully, but these errors were encountered:
Describe the bug
The current implementation of e.g.
Length.Equals(Length other, Length tolerance)
can lead to false negatives at the boundaries of the tolerance (for instance when comparinga
witha - tolerance
).To Reproduce
The assert fails, which makes sense if you rephrase it as
Assert.True(((length - tolerance) - length).Abs() <= tolerance);
which also fails as
((length - tolerance) - length).Abs().Millimeters == 0.50000000000000044
due to floating-point arithmetic.
Expected behavior
That the above Assert with Equals returns true.
Additional context
Tried it with UnitsNet 4.132.0, 5.43.0 and on the current master branch (1b3647f).
The text was updated successfully, but these errors were encountered: