diff src/OPERATORS/op-s-s.cc @ 9551:19d298e6f7e5

make ! operator check for NaNs, simplify implementations in liboctave
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 21 Aug 2009 08:18:16 +0200
parents eb63fbe60fab
children ac4b97c6bf8b
line wrap: on
line diff
--- a/src/OPERATORS/op-s-s.cc	Wed Aug 19 22:55:15 2009 +0200
+++ b/src/OPERATORS/op-s-s.cc	Fri Aug 21 08:18:16 2009 +0200
@@ -25,6 +25,8 @@
 #include <config.h>
 #endif
 
+#include "Array-util.h"
+
 #include "gripes.h"
 #include "oct-obj.h"
 #include "ov.h"
@@ -40,7 +42,15 @@
 
 // scalar unary ops.
 
-DEFUNOP_OP (not, scalar, !)
+DEFUNOP (not, scalar)
+{
+  CAST_UNOP_ARG (const octave_scalar&);
+  double x = v.scalar_value ();
+  if (xisnan (x))
+    gripe_nan_to_logical_conversion ();
+  return octave_value (x == 0.0);
+}
+
 DEFUNOP_OP (uplus, scalar, /* no-op */)
 DEFUNOP_OP (uminus, scalar, -)
 DEFUNOP_OP (transpose, scalar, /* no-op */)