Search code examples
booleanoctaveboolean-expressionboolean-operationsoctave-gui

Octave: Boolean AND returns wrong number


I am trying for several hours to calculate a boolean AND operation in Octave. It return a wrong number.

I want to calculate following numbers: result = 4037 & 63 result should be 5 but i get 1.

I also tried result = and(4037, 63) but i get 1 again

Why is this happening?


Solution

  • Both approaches are not meant to be used for bitwise operations. Instead, you should use bitand function:

    result = bitand(4037, 63)