Mercurial > hg > octave-nkf
changeset 19393:566ea8a8683b
Return correct type from bitwise operators on logical arguments (bug #43273)
* bitfcns.cc (bitop): Return a logical value when both arguments are
logical values.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Wed, 01 Oct 2014 22:47:53 -0400 |
parents | 068a3e51b7b8 |
children | 4871d0ecbfa7 |
files | libinterp/corefcn/bitfcns.cc |
diffstat | 1 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/bitfcns.cc +++ b/libinterp/corefcn/bitfcns.cc @@ -159,6 +159,10 @@ octave_float_scalar::static_class_name () && args(1).class_name () != octave_bool::static_class_name ()); + bool arg0_is_bool = args(0).class_name () == + octave_bool::static_class_name (); + bool arg1_is_bool = args(1).class_name () == + octave_bool::static_class_name (); bool arg0_is_float = args(0).class_name () == octave_float_scalar::static_class_name (); bool arg1_is_float = args(1).class_name () == @@ -166,12 +170,12 @@ if (! (arg0_is_int || arg1_is_int)) { - if (! (arg0_is_float || arg1_is_float)) + if (arg0_is_bool && arg1_is_bool) { - uint64NDArray x (args(0).array_value ()); - uint64NDArray y (args(1).array_value ()); + boolNDArray x (args(0).bool_array_value ()); + boolNDArray y (args(1).bool_array_value ()); if (! error_state) - retval = bitopx (fname, x, y).array_value (); + retval = bitopx (fname, x, y).bool_array_value (); } else if (arg0_is_float && arg1_is_float) { @@ -180,6 +184,13 @@ if (! error_state) retval = bitopx (fname, x, y).float_array_value (); } + else if (! (arg0_is_float || arg1_is_float)) + { + uint64NDArray x (args(0).array_value ()); + uint64NDArray y (args(1).array_value ()); + if (! error_state) + retval = bitopx (fname, x, y).array_value (); + } else { int p = (arg0_is_float ? 1 : 0);