New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix machine epsilon for double #4096
Fix machine epsilon for double #4096
Conversation
@rstm-sf is this something we should also upstream to dotnet? so that double.Epsilon is correct in the framework? |
@rstm-sf i think this PR could be expanded elsewhere in the whole repo since we use double.Epsilon alot. |
There is another class similar to
Which is better to choose? |
Even WPF has like 3 copies of this class, each one with a different constant. Would need to figure what is the reason behind it. |
It seems to me that so historically. I prefer the single-precision option, since the pixels are integer? |
Depends during which phase - during layout (and many of our calculation happen during this phase) pixels are floating point due to DPI scaling. So even if user is using integers values everything will get multiplied by a scaling factor. Because of that one must be quite careful since precision errors accumulate easily and one of the reasons why layout has own set of rounding functions. |
Ok, now I began to think that the error for double precision is better |
Maybe it’s worth just creating a methods with a |
Problem is that almost all of our calculations are done using double precision (I am still not sure why WPF is using double and not single precision), so exposing single precision API will both force users to cast and potentially introduce truncation errors. |
I mean, it’s better to add similar checks for single precision ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
What does the pull request do?
Fixing inaccuracy in machine epsilon found by @MarchingCube #4092 (comment)
What is the current behavior?
The result of methods from the
MathUtilities
class using machine epsilon was not always correct.What is the updated/expected behavior with this PR?
The result of methods from the
MathUtilities
class using machine epsilon.Checklist