> (Sometimes I think there should be a separate Real type that ordinary
> users work with, leaving all the fun of FP to hard-core numericists).

Might be a good idea not only because of NaN:
One of the first lessons in numerical analysis is that equality is brittle for 
floats, thus you check the magnitude of their delta instead.

For advanced users this is only tedious, but newbies in the field of software 
development often have to learn the hard way.
The whole problem could be avoided easily, but sadly, there is no obvious 
choice for the tolerance of the check — unless Swift adds support for generic 
value parameters, which could be used to define something like
typealias Velocity = FloatingPoint<precision: 0.01>
Such a type would break some mathematical rules, but hey, if a == sqrt(a) * 
sqrt(a) can be false, why not use a type that violates a == b => !(a < b) && 
!(a > b), but in exchange offers some nice convenience?
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to