[m-dev.] float regression

Zoltan Somogyi zs at csse.unimelb.edu.au
Thu Aug 25 17:06:42 AEST 2011

When investigating a test case failure, I came across this difference
between the code of library/float.c in grade hlc.gc:

--- library/float.c	2011-08-25 14:39:59.968258931 +1000
+++ stage2/library/float.c	2011-08-25 14:50:45.312467217 +1000
@@ -974,7 +974,7 @@
     mercury__float__succeeded = (mercury__float__Num_3 <= mercury__float__V_5_5);
     if (mercury__float__succeeded)
-      mercury__float__Abs_4 = (((MR_Float) 0.0000000000000000) - mercury__float__Num_3);
+      mercury__float__Abs_4 = (((MR_Float) 5.9154716928082453e-317) - mercury__float__Num_3);
       mercury__float__Abs_4 = mercury__float__Num_3;
     return mercury__float__Abs_4;
@@ -1175,7 +1175,7 @@
     MR_bool mercury__float__succeeded;
-    MR_Float mercury__float__HeadVar__2_2 = (((MR_Float) 0.0000000000000000) - mercury__float__HeadVar__1_1);
+    MR_Float mercury__float__HeadVar__2_2 = (((MR_Float) 5.9154716928082453e-317) - mercury__float__HeadVar__1_1);
     return mercury__float__HeadVar__2_2;

library/float.c was generated by a compiler I installed on my laptop on Aug 16,
while stage2/library/float.c was generated by an up-to-date compiler.
The differences are in the implementation of the absolute value function
and the unary minus function. There is a similar difference in math.c.

The test case failures I was investigating are in tests/term, and involve
differences in the output of the old termination analysis system, which uses
float math, some of which is sensitive to such imprecision. I don't know
for certain yet, but these diffs could have caused the test case failures.

This seems to me to be a clear regression. Peter, can you please look into
whether one of your changes to floats caused this?

PS: I was teaching my students in "Programming the Machine" just yesterday
about the weird properties of float operations, like x > 0 not implying
x + y > y. Ironic, huh?

mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au

More information about the developers mailing list