diff liboctave/oct-cmplx.h @ 9667:641a788c82a4

fix complex-real comparisons
author Jaroslav Hajek <highegg@gmail.com>
date Sun, 27 Sep 2009 12:11:33 +0200
parents 8bea4e89326f
children 4c0cdbe0acca
line wrap: on
line diff
--- a/liboctave/oct-cmplx.h
+++ b/liboctave/oct-cmplx.h
@@ -53,26 +53,26 @@
 template <class T> \
 inline bool operator OP (const std::complex<T>& a, T b) \
 { \
-  FLOAT_TRUNCATE const T ax = std::abs (a); \
-  if (ax == b) \
+  FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
+  if (ax == bx) \
     { \
       FLOAT_TRUNCATE const T ay = std::arg (a); \
       return ay OP 0; \
     } \
   else \
-    return ax OPS b; \
+    return ax OPS bx; \
 } \
 template <class T> \
 inline bool operator OP (T a, const std::complex<T>& b) \
 { \
-  FLOAT_TRUNCATE const T bx = std::abs (b); \
-  if (a == bx) \
+  FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \
+  if (ax == bx) \
     { \
       FLOAT_TRUNCATE const T by = std::arg (b); \
       return 0 OP by; \
     } \
   else \
-    return a OPS bx; \
+    return ax OPS bx; \
 }
 
 DEF_COMPLEXR_COMP (>, >)