bugGNU Octave - Bugs: bug #35621, invert function bin2dec of dec2bin

 
 

bug #35621: invert function bin2dec of dec2bin

Submitter:  None
Submitted:  Fri 24 Feb 2012 05:01:50 PM UTC
   
 
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  bin2dec Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.4.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 24 Feb 2012 11:04:12 PM UTC, comment #1: 

Fixed in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/731e9e1539a8) on the stable branch.  The correct behavior will be available at the next patch release 3.6.2.  Alternatively, you can build from the stable Mercurial branch to access the fix immediately.

Rik <rik5>
Group administrator
Fri 24 Feb 2012 05:01:50 PM UTC, original submission:  

bin2dec seem to be the invert function dec2bin.
So, we expect this kind of result:

bin2dec( dec2bin( X )) == X

BUT It don't occur for X valued with 0 and 1 !


Example 1:

octave:1> bin2dec(dec2bin(0:4))'
ans =

   0   1   2   3   4

octave:2> bin2dec(dec2bin(0:3))'
ans =

   0   1   2   3

octave:3> bin2dec(dec2bin(0:2))'
ans =

   0   1   2

octave:4> bin2dec(dec2bin(0:1))'
ans =  1

octave:5> bin2dec(dec2bin(0:0))'
ans = 0



Example 2:

octave:30> bin2dec(dec2bin([1 0 3]))
ans =

   1
   0
   3

octave:31> bin2dec(dec2bin([1 0 3])')
ans =

   1
   5

That's OK, but:

octave:34> bin2dec(dec2bin([1 0 0 1 0 1 0]))
ans =  74

octave:35> bin2dec(dec2bin([1 0 0 1 0 1 0])')
ans =  74

Should not have this behavior.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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)
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2012-02-24 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.14-d582.
    Corresponding source code