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?
algaimplements theLatticetrait for primitivef32andf64types while providing infallible pair-wisemeetandjoinoperations. This seems to interact poorly withNaNs, which do not compare with other floating point values regardless of what they encode (the result is alwaysfalsewith the sole exception of!=).Given this comparison and some floating point value
x,(NaN ∨ x)producesxwhile(x ∨ NaN)producesNaN, becauseNaN >= xandx >= NaNare never true. Considering thatNaNhas 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 viaOptionorResult), then perhaps the implementation should produceNaNif either operand isNaN. "Garbage in, garbage out" probably applies here as well. :-) Do you have any thoughts on this?