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

 
 

bug #35621: invert function bin2dec of dec2bin

Submitted by:  None
Submitted on:  Fri 24 Feb 2012 05:01:50 PM UTC  
 
Category: LibrariesSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: bin2decOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.4.3
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project 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 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 rik5 (Posted a comment)
  •  

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

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 24 Feb 2012 11:04:12 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1