bugGNU Octave - Bugs: bug #36458, Bitset error

 
 

bug #36458: Bitset error

Submitted by:  Fu Juay Chang <richerard>
Submitted on:  Sun 13 May 2012 12:09:07 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.6.1Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Mon 14 May 2012 04:48:22 AM UTC, comment #3:

The following patch fixes the bug for me:

http://hg.savannah.gnu.org/hgweb/octave/rev/056ea51070b8

Closing this report. If there are outstanding problems, please reopen this.

Jordi GutiƩrrez Hermoso <jordigh>
Project Administrator
Sun 13 May 2012 03:39:24 PM UTC, comment #2:

Matlab (R2009B) says:

>> a=uint8([1,2;3 4])


a =

1 2
3 4

>> bitset(a,1,[0 1; 0 1])


ans =

0 3
2 5

and:

>> help bitset

BITSET Set bit.
C = BITSET(A,BIT) sets bit position BIT in A to 1 (on). A must be an
unsigned integer or an array of unsigned integers, and BIT must be a
number between 1 and the length in bits of the unsigned integer class
of A, e.g., 32 for UINT32s.

C = BITSET(A,BIT,V) sets the bit at position BIT to the value V.
V must be either 0 or 1.

Example:
Repeatedly subtract powers of 2 from the largest UINT32 value:

a = intmax('uint32')
for i = 1:32, a = bitset(a,32-i+1,0), end

See also BITGET, BITAND, BITOR, BITXOR, BITCMP, BITSHIFT, INTMAX.

So, it is a little unclear what if anything should be
done about this. Possibly check for valid third argument?

In any case, what was the motivation for a vector third
argument which Matlab does not officially support?

Michael Godfrey <godfrey>
Project Member
Sun 13 May 2012 03:01:53 PM UTC, comment #1:

The third argument is expected to be a scalar. From 'help bitset':

VAL = 0 resets and VAL = 1 sets the bits.

You can do something like this instead:

This is working correctly as it is documented. I don't think this is Matlab behavior either. Are you requesting this as a new feature?

Mike Miller <mtmiller>
Project Administrator
Sun 13 May 2012 12:09:07 PM UTC, original submission:

>> a=uint8([1, 2;3 4])

a =

1 2
3 4

>> bitset(a, 1, [0 1; 0 1])

ans =

0 2
2 4

----------------------------------------
The result is incorrect. It should be

ans =
0 3
2 5

Fu Juay Chang <richerard>

 

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

Attach File(s):
   
   
Comment:
   

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 jordigh (Updated the item)
  • -unavailable- added by godfrey (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by richerard (Submitted the item)
  • -unavailable- added by richerard
  •  

    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 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 14 May 2012 04:48:22 AM UTCjordighStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
      Operating SystemMicrosoft Windows=>Any
    Sun 13 May 2012 04:19:11 PM UTCjordighSummaryBitset error!=>Bitset error
    Sun 13 May 2012 03:01:53 PM UTCmtmillerStatusNone=>Need Info
    Sun 13 May 2012 12:09:07 PM UTCricherardCarbon-Copy-=>Added richerard

    Back to the top


    Powered by Savane 3.1-cleanup1