[MLton-user] bug with floating-point division on x86/Mac OS X

John Reppy jhr at cs.uchicago.edu
Sat May 30 12:31:32 PDT 2009


The code generation for floating-point division is broken in certain  
situations
on the x86 (Mac OS X).  Here is a small program that demonstrates the  
bug:

   structure R = Real64 (* or Real32 *)

   fun f (a, b) = let
         val c = a / b
         in
	  print(concat[R.toString a, "/", R.toString b, " = ", R.toString c,  
"\n"])
         end;

   val _ = List.app f [(0.5, 2.0), (0.5, 130.0)];

It prints:

   0.5/2 = 4
   0.5/130 = 260

when it should print something like

   0.5/2 = 0.25
   0.5/130 = 0.00384615384615

The MLton version is revision 7103 from svn and I'm running on Mac OS  
X 10.5.7.
The bug affects both 32 and 64-bit floats.

	- John




More information about the MLton-user mailing list