Considering NaN, do floating point values form a lattice?
- Dominant language
- Rust
- Stars
- 201
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
`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 `NaN`s, 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](https://github.com/rustsim/alga/blob/cbd5a51ae61939ea3e791304305053745adb713e/alga/src/general/lattice.rs#L98) 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 `NaN`s 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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.