Mercurial > hg > octave-lojdl
changeset 9440:357cff83985d
fix signed integer shift
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 20 Jul 2009 11:51:10 +0200 |
parents | 0a696f8aa434 |
children | 160c564d5d25 |
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)