> On Apr 24, 2017, at 10:06 PM, Jonathan Hull via swift-evolution 
> <[email protected]> wrote:
> 
> As I am thinking about it more, this means that for == and <
> 
> NaN == NaN
> -0 == +0
> +Inf < NaN
> 
> Since this would break from IEEE, I think we should also consider taking the 
> opportunity to make == and < work with a default tolerance.  That is, 'a == 
> b' would check that (a - b) < epsilon for some reasonable choice of epsilon 
> that works for common usage.  I know this would make the hash function harder 
> to write, but I think it is worthwhile.

It’s possible to tinker with IEEE comparisons and maybe improve them or at 
least work to make them compatible in some way with the expectations of 
Comparable. Making them have a tolerance by default is out of the question, 
however: as soon as you add a tolerance, you give up transitivity of equality, 
which is a much, much worse violation of the axioms than anything inflicted by 
the presence of NaN in the IEEE 754 model.

– Steve
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to