# HG changeset patch # User Rik # Date 1330124516 28800 # Node ID 731e9e1539a818d39fa29c586c92a0d024ad7c62 # Parent 670feb71afdef1db7574bc8ca91d98b5a3baff85 base2dec.m: Fix incorrect bin2dec results (bug #35621). * base2dec.m: Fix incorrect bin2dec results (bug #35621). diff --git a/scripts/strings/base2dec.m b/scripts/strings/base2dec.m --- 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");