Skip to content
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

Considering NaN, do floating point values form a lattice? #96

Open
olson-sean-k opened this issue Apr 24, 2020 · 0 comments
Open

Considering NaN, do floating point values form a lattice? #96

olson-sean-k opened this issue Apr 24, 2020 · 0 comments

Comments

@olson-sean-k
Copy link

alga implements the Lattice trait for primitive f32 and f64 types while providing infallible pair-wise meet and join operations. This seems to interact poorly with NaNs, which do not compare with other floating point values regardless of what they encode (the result is always false with the sole exception of !=).

Given this comparison and some floating point value x, (NaN ∨ x) produces x while (x ∨ NaN) produces NaN, because NaN >= x and x >= NaN are never true. Considering that NaN has no ordering w.r.t. any elements in the set of floating point values, can there be a greatest lower bound or least upper bound?

If the intention is to simply propagate NaNs as a sort of special case (rather than using a fallible API via Option or Result), then perhaps the implementation should produce NaN if either operand is NaN. "Garbage in, garbage out" probably applies here as well. :-) Do you have any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant