Mercurial > hg > octave-nkf
changeset 14404:731e9e1539a8 stable
base2dec.m: Fix incorrect bin2dec results (bug #35621).
* base2dec.m: Fix incorrect bin2dec results (bug #35621).
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 24 Feb 2012 15:01:56 -0800 |
parents | 670feb71afde |
children | 73f02881260f |
files | scripts/strings/base2dec.m |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/strings/base2dec.m +++ b/scripts/strings/base2dec.m @@ -89,7 +89,7 @@ table = NaN (1, 256); table(toascii (symbols(1:base))) = 0 : base-1; table(toascii (" ")) = 0; - s = table(toascii (s)); + s = reshape (table(toascii (s)), size (s)); ## Multiply the resulting digits by the appropriate power ## and sum the rows. @@ -103,6 +103,9 @@ %!assert(base2dec ("-1", 2), NaN); %!assert(base2dec ({"A1", "1A"}, 16), [161; 26]); +%% Bug #35621 +%!assert (base2dec (["0"; "1"], 2), [0; 1]) + %%Test input validation %!error base2dec (); %!error base2dec ("11120");