Mercurial > hg > octave-nkf
changeset 12045:42d51e66729b release-3-2-x
fix signed integer shift
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 25 Jul 2009 16:20:35 +0200 |
parents | 8dcae1dfc9a0 |
children | efdc5df061b6 |
files | src/ChangeLog src/bitfcns.cc |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-07-20 Jaroslav Hajek <highegg@gmail.com> + + * bitfcns.cc (DO_UBITSHIFT): Avoid overflow. + (DO_SBITSHIFT): Fix mask calculation. + 2009-07-17 Benjamin Lindner <lindnerb@users.sourceforge.net> * DLD-FUNCTIONS/__magick_read__.cc (F__magick_read__):
--- a/src/bitfcns.cc +++ b/src/bitfcns.cc @@ -381,7 +381,7 @@ { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ - octave_ ## T mask = ~0ULL; \ + octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ @@ -395,11 +395,12 @@ { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ - octave_ ## T mask = -1; \ + octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ mask = 0; \ + mask = mask | octave_ ## T :: min (); /* FIXME: 2's complement only? */ \ DO_BITSHIFT (T); \ } \ while (0)