benchmarking Poly/ML & floating point
Stephen Weeks
MLton@sourcelight.com
Mon, 11 Sep 2000 14:46:49 -0700 (PDT)
> The IEEE spec says that comparisons (equal, not-equal, less, ...) all return
> false if either is a NAN, but I don't know what the ML spec says. There are
> strong arguments for NOT requiring this in a language spec. It would mean
> that you can't efficiently reverse branch conditions, for instance.
The SML spec requires IEEE compliance. It also says that != is equivalent to
"not o ==", which is the same as the IEEE ?<> operator.
I now believe I understand what is going on. In C, x != y is exactly equivalent
to !(x == y). Thus, the definitions of Real_nequal and Real_equal in
mlton-lib.h are correct. Although there's still no reason I can see for keep
around the primitive Real_nequal, since it is just not o Real.==. As to
Real.qequal, I bet the definition in mlton-lib.h is wrong, since it is
equivalent (I believe) to Real_equal. I don't know if there is a way to get
what we want in one C operator. So, my bet as to the right thing to do is to
drop Real_qequal as a primitive and to define Real.qequal in the basis library
as
val op ?= = fn (x, y) => isNan x orelse isNan y orelse x == y