lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Unit test for C99 round()


From: Greg Chicares
Subject: [lmi] Unit test for C99 round()
Date: Tue, 03 Jun 2008 16:34:26 +0000
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Would you please run the new 'round_test' on GNU/Linux, both
 - without modification; and
 - with the patch below [1];
and describe its results here? (I've added it to 'Makefile.am'.)
I'm wondering whether it'll report any problems with glibc, most
particularly with the patch.

If output is voluminous, this would be a reasonable abridgement:
  path/to/round_test |sed -e'/^Rounding\|tests/!d'

Here's why I ask. MinGW is planning to replace its implementation
of the round() family. There are some issues with its present
implementation, but the new one passes all these tests, even with
the strict-equality patch. I'm trying to decide whether to commit
the patch. I'd guess it's reasonable enough to commit it if both
glibc and MinGW's own implementation pass every test. It seems
easier to ask for this "reality check" than to attempt to prove
that C99 actually requires expected and observed values to match
perfectly.

---------

[1] patch to require strict equality:

Index: round_test.cpp
===================================================================
RCS file: /sources/lmi/lmi/round_test.cpp,v
retrieving revision 1.2
diff -u -r1.2 round_test.cpp
--- round_test.cpp      3 Jun 2008 14:35:32 -0000       1.2
+++ round_test.cpp      3 Jun 2008 14:53:15 -0000
@@ -279,7 +279,7 @@
     // constants as if at runtime [F.7.4/1].
     max_prec_real tolerance = std::numeric_limits<RealType>::epsilon();

-    bool error_is_within_tolerance = rel_error <= tolerance;
+    bool error_is_within_tolerance = observed == expected;

     if(!error_is_within_tolerance)
         {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]