summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve M. Robbins <smr@sumost.ca>2007-03-05 02:17:27 +0000
committerSteve M. Robbins <smr@sumost.ca>2007-03-05 02:17:27 +0000
commit74b3222b58ac7fc3ac2740ab121586a5ac4ef8fe (patch)
tree47e1fe3e960693f3410a47818b56e43fc68132d9
parent82fb2eaf5c99b6399824128495af32c8c0570df8 (diff)
Make floatingPointIsFinite() return int. Fix comment about comparisons and IEEE NaN.
-rw-r--r--ChangeLog5
-rw-r--r--include/cppunit/portability/FloatingPoint.h13
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 7e47be2..3225141 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-04 Steve M. Robbins <smr@sumost.ca>
+
+ * include/cppunit/portability/FloatingPoint.h (floatingPointIsFinite): Change
+ return type to int, following the convention of isfinite(), finite(), etc.
+
2007-02-25 Baptiste Lepilleur <blep@users.sourceforge.net>
* doc/cookbook.dox: changed suite() to return a TestSuite instead
diff --git a/include/cppunit/portability/FloatingPoint.h b/include/cppunit/portability/FloatingPoint.h
index 584c433..e8c91b3 100644
--- a/include/cppunit/portability/FloatingPoint.h
+++ b/include/cppunit/portability/FloatingPoint.h
@@ -7,8 +7,11 @@
CPPUNIT_NS_BEGIN
/// \brief Tests if a floating-point is a NaN.
-// According to IEEE-754 floating point standard, NaN comparison should always
-// be 'false'.
+// According to IEEE-754 floating point standard,
+// (see e.g. page 8 of
+// http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps)
+// all comparisons with NaN are false except "x != x", which is true.
+//
// At least Microsoft Visual Studio 6 is known not to implement this test correctly.
// It emits the following code to test equality:
// fcomp qword ptr [nan]
@@ -32,12 +35,12 @@ inline bool floatingPointIsUnordered( double x )
/// \brief Tests if a floating-point is finite.
/// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise.
-inline bool floatingPointIsFinite( double x )
+inline int floatingPointIsFinite( double x )
{
#if defined(CPPUNIT_HAVE_ISFINITE)
- return (bool)isfinite( x );
+ return isfinite( x );
#elif defined(CPPUNIT_HAVE_FINITE)
- return (bool)finite( x );
+ return finite( x );
#elif defined(CPPUNIT_HAVE__FINITE)
return _finite(x);
#else