Commits

ssn...@4525493e-7705-40b1-a816-d608a930855b  committed 96098ea

Make fpcompare.h more robust.

  • Participants
  • Parent commits 0424fb1

Comments (0)

Files changed (2)

 2008-09-29  scott snyder  <snyder@bnl.gov>
 
+	* Tagging CxxUtils-00-00-03.
+	* CxxUtils/fpcompare.h: Make more robust.
+
 	* Tagging CxxUtils-00-00-02.
 	* CxxUtils/fpcompare.h: (new)
 	* test/fpcompare_test.cxx: (new)

File CxxUtils/fpcompare.h

 // This file's extension implies that it's C, but it's really -*- C++ -*-.
-// $Id: fpcompare.h,v 1.1 2008-09-29 19:51:59 ssnyder Exp $
+// $Id: fpcompare.h,v 1.2 2008-09-29 20:26:41 ssnyder Exp $
 
 /**
  * @file CxxUtils/fpcompare.h
  * @return @a a > @a b
  */
 inline
-bool greater (CXXUTILS_FPCOMPARE_VOLATILE double a,
-              CXXUTILS_FPCOMPARE_VOLATILE double b)
+bool greater (double a, double b)
 {
-  return a > b;
+  CXXUTILS_FPCOMPARE_VOLATILE double va = a;
+  CXXUTILS_FPCOMPARE_VOLATILE double vb = b;
+  return va > vb;
 }
 
 
  * @return @a a < @a b
  */
 inline
-bool less (CXXUTILS_FPCOMPARE_VOLATILE double a,
-           CXXUTILS_FPCOMPARE_VOLATILE double b)
+bool less (double a, double b)
 {
-  return a < b;
+  CXXUTILS_FPCOMPARE_VOLATILE double va = a;
+  CXXUTILS_FPCOMPARE_VOLATILE double vb = b;
+  return va < vb;
 }
 
 
  * @return @a a >= @a b
  */
 inline
-bool greater_equal (CXXUTILS_FPCOMPARE_VOLATILE double a,
-                    CXXUTILS_FPCOMPARE_VOLATILE double b)
+bool greater_equal (double a, double b)
 {
-  return a >= b;
+  CXXUTILS_FPCOMPARE_VOLATILE double va = a;
+  CXXUTILS_FPCOMPARE_VOLATILE double vb = b;
+  return va >= vb;
 }
 
 
  * @return @a a <= @a b
  */
 inline
-bool less_equal (CXXUTILS_FPCOMPARE_VOLATILE double a,
-                 CXXUTILS_FPCOMPARE_VOLATILE double b)
+bool less_equal (double a, double b)
 {
-  return a <= b;
+  CXXUTILS_FPCOMPARE_VOLATILE double va = a;
+  CXXUTILS_FPCOMPARE_VOLATILE double vb = b;
+  return va <= vb;
 }