Mercurial > hg > octave-nkf
diff liboctave/util/oct-inttypes.h @ 18775:37c300acfcfd stable
don't truncate when casting char to uintN values (bug #42054)
* oct-inttypes.h (octave_int<T>::octave_int (char)):
New special case constructor.
* oct-inttypes.cc: New tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 05 Apr 2014 15:09:09 -0400 |
parents | 284e5c87f27b |
children | 5b6901b06106 |
line wrap: on
line diff
--- a/liboctave/util/oct-inttypes.h +++ b/liboctave/util/oct-inttypes.h @@ -830,6 +830,11 @@ octave_int (T i) : ival (i) { } + // Always treat characters as unsigned. + octave_int (char c) + : ival (octave_int_base<T>::truncate_int (static_cast<unsigned char> (c))) + { } + octave_int (double d) : ival (octave_int_base<T>::convert_real (d)) { } octave_int (float d) : ival (octave_int_base<T>::convert_real (d)) { }