benchmarking Poly/ML & floating point

Matthew Fluet Matthew Fluet <fluet@CS.Cornell.EDU>
Mon, 11 Sep 2000 19:03:05 -0400 (EDT)


So, here's a quick little case I put together to check the changes I made
to the translations of Real_{ne,e,qe}qual:

val x = 1.0/0.0 + ~1.0/0.0;
val _ = print (concat["x = ", 
		      Real.toString x, "\n",
		      "Real.==(x,x) = ", 
		      Bool.toString (Real.==(x,x)), "\n",
		      "Real.!=(x,x) = ", 
		      Bool.toString (Real.!=(x,x)), "\n",
		      "Real.?=(x,x) = ", 
		      Bool.toString (Real.?=(x,x)), "\n",
		      Real.toString x, "\n",
		      "Real.==(x,1.0) = ", 
		      Bool.toString (Real.==(x,1.0)), "\n",
		      "Real.!=(x,1.0) = ", 
		      Bool.toString (Real.!=(x,1.0)), "\n",
		      "Real.?=(x,1.0) = ", 
		      Bool.toString (Real.?=(x,1.0)), "\n",
		      Real.toString 1.0, "\n",
		      "Real.==(1.0,1.0) = ", 
		      Bool.toString (Real.==(1.0,1.0)), "\n",
		      "Real.!=(1.0,1.0) = ", 
		      Bool.toString (Real.!=(1.0,1.0)), "\n",
		      "Real.?=(1.0,1.0) = ", 
		      Bool.toString (Real.?=(1.0,1.0)), "\n"]);

(x86) MLton output:
Real.==(x,x) = false
Real.!=(x,x) = true
Real.?=(x,x) = true
Real.==(x,1.0) = false
Real.!=(x,1.0) = true
Real.?=(x,1.0) = true
Real.==(1.0,1.0) = true
Real.!=(1.0,1.0) = false
Real.?=(1.0,1.0) = true

(C) MLton output: using the new proposal for Real_qequal
x = nan
Real.==(x,x) = false
Real.!=(x,x) = true
Real.?=(x,x) = true
Real.==(x,1.0) = false
Real.!=(x,1.0) = true
Real.?=(x,1.0) = true
Real.==(1.0,1.0) = true
Real.!=(1.0,1.0) = false
Real.?=(1.0,1.0) = true

So, x86 MLton and C MLton are consistent.  However:

SML/NJ output:
x = nan
Real.==(x,x) = false
Real.!=(x,x) = false
Real.?=(x,x) = true
Real.==(x,1.0) = false
Real.!=(x,1.0) = false
Real.?=(x,1.0) = true
Real.==(1.0,1.0) = true
Real.!=(1.0,1.0) = false
Real.?=(1.0,1.0) = true


So MLton and/or SML/NJ and/or the Basis Library spec are wrong.  SML/NJ
doesn't follow the requirement that Real.!= is equivalent to not o Real.==.
On the other hand, as a friend of mine remarked, is it even true that 
not o Real.== is equivalent to the IEEE ?<> operator?