octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #35621] invert function bin2dec of dec2bin


From: anonymous
Subject: [Octave-bug-tracker] [bug #35621] invert function bin2dec of dec2bin
Date: Fri, 24 Feb 2012 17:01:51 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0

URL:
  <http://savannah.gnu.org/bugs/?35621>

                 Summary: invert function bin2dec of dec2bin
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Fri 24 Feb 2012 05:01:50 PM UTC
                Category: Libraries
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: bin2dec
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.4.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:

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.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?35621>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]