bugGNU Octave - Bugs: bug #49168, Wrong results with logical AND

 
 

bug #49168: Wrong results with logical AND

Submitter:  Simon <simonz>
Submitted:  Fri 23 Sep 2016 03:55:11 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 23 Sep 2016 04:01:30 PM UTC, comment #1: 

See the documentation for and:


 -- Z = and (X, Y)
 -- Z = and (X1, X2, ...)
     Return the logical AND of X and Y.

     This function is equivalent to the operator syntax 'x & y'.  If
     more than two arguments are given, the logical AND is applied
     cumulatively from left to right:

          (...((x1 & x2) & x3) & ...)

     At least one argument is required.

     See also: or, not, xor.


The construction


and (0x05, 0x02)


is equivalent to


logical (0x05) & logical (0x02)
=>
true & true
=>
true


See the function bitand for what you are trying to do.


  -- bitand (X, Y)
     Return the bitwise AND of non-negative integers.

     X, Y must be in the range [0,intmax]

     See also: bitor, bitxor, bitset, bitget, bitcmp, bitshift, intmax,
     flintmax.


With your sample input


bitand (0x05, 0x02)
ans = 0



Rik <rik5>
Group administrator
Fri 23 Sep 2016 03:55:11 PM UTC, original submission:  

Hi,

When I execute

and(0x05,0x02)

Octave returns 1. I think it should be 0 since the bitwise AND:

0101 & 0010 = 0x0000

Regards,
Simon

Simon <simonz>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #38592:  xxx.png added by simonz (49KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by simonz (Submitted the item)
  • -email is unavailable- added by simonz
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-23 rik5 StatusNone Invalid / Not an Octave Bug
        Open/ClosedOpen Closed
    2016-09-23 simonz Attached File- Added xxx.png, #38592
        Carbon-Copy- Added simonz

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code