Mercurial > hg > octave-nkf
diff liboctave/oct-inttypes.h @ 8104:fc45357bf50c
fix integer exponentiation with negative exponent
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 12 Sep 2008 15:34:13 -0400 |
parents | cd90e2842080 |
children | 66bc6f9b4f72 |
line wrap: on
line diff
--- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -481,10 +481,15 @@ octave_int<T> zero = octave_int<T> (0); octave_int<T> one = octave_int<T> (1); - if (b == zero) + if (b == zero || a == one) retval = one; else if (b < zero) - retval = zero; + { + if (std::numeric_limits<T>::is_signed && a.value () == -1) + retval = (b.value () % 2) ? a : one; + else + retval = zero; + } else { octave_int<T> a_val = a;