octave-maintainers
[Top][All Lists]
Advanced

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

Re: bin2dec behavior different from Matlab?


From: Daniel J Sebald
Subject: Re: bin2dec behavior different from Matlab?
Date: Wed, 21 Mar 2012 11:31:31 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 03/21/2012 05:01 AM, ahowe42 wrote:
If a string holds data that is too be operated upon, every character should
be meaningful.  Using [1 0 1] to indicate [101] is bad programming practice,
and an (admittedly small) inefficiency.  I have also done MATLAB programming
using binary strings and bin2dec / dec2bin, and never included unnecessary
spaces (actually, logical arrays are much more useful and should be faster).

Is this really something that should be "fixed"?

Yes.


spaces (actually, logical arrays are much more useful and should be faster).

octave:1> x = [1 0 1] == 1
x =

   1   0   1

octave:2> class(x)
ans = logical
octave:3> bin2dec(x)
error: base2dec: S must be a string or cellstring
error: called from:
error:   /home/sebald/octave/base2dec.m at line 63, column 5
error:   /home/sebald/octave/bin2dec.m at line 48, column 5


Maybe more than one thing.

Dan


reply via email to

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