-
Notifications
You must be signed in to change notification settings - Fork 8
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 signed zero bugs & refine numeric restrictions #537
Comments
This will be used to enforce stronger restrictions on color components, which will reduce the number of edge cases color processing code must consider, and remove the the hazard of distinct negative zero (<#537>).
It is now impossible for colors to contain negative components, which will reduce the number of edge cases color processing code must consider, and remove the the hazard of distinct negative zero (<#537>). (There are some uses for negative-valued RGB components to represent colors that are outside of the gamut of the chosen color space, but I don’t know enough about that extension to know how to handle it correctly.) We’re probably also going to want a type restricted from 0 to 1, for strict alpha and reflectance calculations, but `PositiveSign` is a straightforward improvement of the overall situation.
Commit 20cd9d6 replaces all uses of Next steps:
|
As of commit ef1a45e, there is a |
As of commit 30ceaed, |
Remaining non-incidental uses of
|
This is part of <#537> — `PositiveSign` gives us a guarantee of no negative zeroes, which compare equal to positive zeroes. Also, it makes sense to restrict the range to positive since this is the length of a velocity vector.
Part of <#537>. This doesn’t directly remove any negative-zero hazards, but it is a more appropriately bounded data type regardless (frame time cannot be negative).
Whoops, the design of My first thought is to define multiplication such that |
Implemented |
Problem
There's a correctness bug lurking in our use of
ordered_float::NotNan
: positive and negative zero,-0.0
and0.0
, compare equal, and this can cause different outcomes of further operations (notably division or reciprocal). This means that using them as cache keys is invalid except where the sign is known to make no difference.Closely related, but not strictly a bug: there are cases where
NotNan
is less restrictive than we would benefit from; for example,Rgba
allows an alpha less than 0 or greater than 1, but this is meaningless.Solution
All of our uses of
NotNan
(we don't have any uses that aren't for cache-key/change-detection purposes, I believe) should be replaced with wrappers that are either more restrictive or consider positive and negative zero distinct, as is appropriate for the application.If some of the resulting wrappers seem more generally applicable, it might make sense to contribute them back to
ordered_float
.The text was updated successfully, but these errors were encountered: