changeset 28144:c31c9eaa1f28 stable

sparse-xpow.cc: use xisint instead of static_cast<int> to check int values
author John W. Eaton <jwe@octave.org>
date Thu, 27 Feb 2020 13:45:53 -0500
parents 4f1d1b1d4afc
children 9e983eb1749d
files libinterp/corefcn/sparse-xpow.cc
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/sparse-xpow.cc	Fri Feb 28 07:59:34 2020 +0100
+++ b/libinterp/corefcn/sparse-xpow.cc	Thu Feb 27 13:45:53 2020 -0500
@@ -67,7 +67,7 @@
   if (nr == 0 || nc == 0 || nr != nc)
     error ("for A^b, A must be a square matrix.  Use .^ for elementwise power.");
 
-  if (static_cast<int> (b) != b)
+  if (! xisint (b))
     error ("use full(a) ^ full(b)");
 
   int btmp = static_cast<int> (b);
@@ -135,7 +135,7 @@
   if (nr == 0 || nc == 0 || nr != nc)
     error ("for A^b, A must be a square matrix.  Use .^ for elementwise power.");
 
-  if (static_cast<int> (b) != b)
+  if (! xisint (b))
     error ("use full(a) ^ full(b)");
 
   int btmp = static_cast<int> (b);
@@ -329,7 +329,7 @@
       octave_idx_type nr = a.rows ();
       octave_idx_type nc = a.cols ();
 
-      if (static_cast<int> (b) != b && a.any_element_is_negative ())
+      if (! xisint (b) && a.any_element_is_negative ())
         {
           ComplexMatrix result (nr, nc, Complex (std::pow (0.0, b)));
 
@@ -363,7 +363,7 @@
           retval = octave_value (result);
         }
     }
-  else if (static_cast<int> (b) != b && a.any_element_is_negative ())
+  else if (! xisint (b) && a.any_element_is_negative ())
     {
       SparseComplexMatrix result (a);
 
@@ -427,7 +427,7 @@
         if (a.data(i) < 0.0)
           {
             double btmp = b (a.ridx (i), j);
-            if (static_cast<int> (btmp) != btmp)
+            if (! xisint (btmp))
               {
                 convert_to_complex = 1;
                 goto done;