bugGNU Octave - Bugs: bug #52174, bitand, bitor, bitxor: support...


bug #52174: bitand, bitor, bitxor: support automatic broadcasting

Submitted by:  sebman <sebma>
Submitted on:  Thu 05 Oct 2017 11:05:30 AM UTC  
Category: Octave FunctionSeverity: 2 - Minor
Priority: 3 - LowItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Mac OS

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Thu 05 Oct 2017 03:45:08 PM UTC, comment #1:

This was a recent change in Matlab R2016b, take a look at https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b/

The bitand, bitor, and bitxor functions are among a handful of others that now support automatic broadcasting when given unlike vectors.

As a workaround for now you can still explicitly use bsxfun

Mike Miller <mtmiller>
Project Administrator
Thu 05 Oct 2017 11:05:30 AM UTC, original submission:


First I have one question, why not migrate to GitHub or other ?
It would be great to be able to use markdown language and preview the bug before we submit it.

Here is the problem with the bitxor function :

On Matlab R2017a ( :

>> byteVector=0:255;
>> data=0:499;
>> whos byteVector data

Name Size Bytes Class Attributes

byteVector 1x256 2048 double
data 1x500 4000 double

>> c=bitxor(byteVector,data);

Error using bitxor
Inputs must have the same size.

>> c=bitxor(byteVector',data); %Transposing the first vector
>> whos c

Name Size Bytes Class Attributes

c 256x500 1024000 double
On Octave 4.2.1 :
octave:1> byteVector=0:255;
octave:2> data=0:499;
octave:3> whos byteVector data
Variables in the current scope:

Attr Name Size Bytes Class
==== ==== ==== ===== =====
byteVector 1x256 24 double
data 1x500 24 double

Total is 756 elements using 48 bytes

octave:4> c=bitxor(byteVector,data);
error: bitxor: size of X and Y must match, or one operand must be a scalar
octave:4> c=bitxor(byteVector',data); %Transposing the first vector
error: bitxor: size of X and Y must match, or one operand must be a scalar
octave:4> whos c

Can you please have a look ?

sebman <sebma>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by sebma (Submitted the item)
  • -unavailable- added by sebma

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 05 Oct 2017 03:45:08 PM UTCmtmillerSeverity3 - Normal=>2 - Minor
      Priority5 - Normal=>3 - Low
      Item GroupIncorrect Result=>Matlab Compatibility
      Summarybitxor does not work between one row vector and one column vector=>bitand, bitor, bitxor: support automatic broadcasting
    Thu 05 Oct 2017 11:05:30 AM UTCsebmaCarbon-Copy-=>Added -unavailable-

    Back to the top

    Powered by Savane 3.1-cleanup1