changeset 8864:4d328b8979c8

simplify integer power
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 25 Feb 2009 06:47:16 +0100
parents 34a821854961
children eace5649a8b5
files liboctave/ChangeLog liboctave/oct-inttypes.cc
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Wed Feb 25 00:41:40 2009 -0500
+++ b/liboctave/ChangeLog	Wed Feb 25 06:47:16 2009 +0100
@@ -1,3 +1,8 @@
+2009-02-25  Jaroslav Hajek  <highegg@gmail.com>
+
+	* oct-inttypes.cc (pow (const octave_int<T>&, const octave_int<T>&)):
+	Simplify.
+
 2009-02-23  Jaroslav Hajek  <highegg@gmail.com>
 
 	* oct-inttypes.h (octave_int_cmp_op::mop): Implement as simple
--- a/liboctave/oct-inttypes.cc	Wed Feb 25 00:41:40 2009 -0500
+++ b/liboctave/oct-inttypes.cc	Wed Feb 25 06:47:16 2009 +0100
@@ -530,15 +530,14 @@
 {
   octave_int<T> retval;
 
-  octave_int<T> zero = octave_int<T> (0);
-  octave_int<T> one = octave_int<T> (1);
+  octave_int<T> zero = static_cast<T> (0);
+  octave_int<T> one = static_cast<T> (1);
 
   if (b == zero || a == one)
     retval = one;
-  // the is_signed check is inserted twice to avoid compiler warnings
-  else if (std::numeric_limits<T>::is_signed && b < zero)
+  else if (b < zero)
     {
-      if (a == octave_int<int> (-1))
+      if (a == -one)
         retval = (b.value () % 2) ? a : one;
       else
         retval = zero;