Mercurial > hg > octave-nkf
diff scripts/strings/bin2dec.m @ 14491:5bd9e47e9277
maint: periodic merge of stable to default
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 22 Mar 2012 11:50:51 -0400 |
parents | cbcaf5602469 e995b1c97e13 |
children | 5d3a684236b0 |
line wrap: on
line diff
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -24,7 +24,17 @@ ## @example ## @group ## bin2dec ("1110") -## @result{} 14 +## @result{} 14 +## @end group +## @end example +## +## Spaces are ignored during conversion and may be used to make the binary +## number more readable. +## +## @example +## @group +## bin2dec ("1000 0001") +## @result{} 129 ## @end group ## @end example ## @@ -50,10 +60,12 @@ endfunction -%!assert (bin2dec ("0000"), 0) -%!assert (bin2dec ("1110"), 14) -%!assert (bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) -%!assert (bin2dec ({"1110", "1111"}), [14; 15]) +%!assert(bin2dec ("0000"), 0) +%!assert(bin2dec ("1110"), 14) +%!assert(bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) +%!assert(bin2dec ({"1110", "1111"}), [14; 15]) +%!assert (bin2dec ("1 0 1"), 5) +%!assert (bin2dec (char ("1 0 1", " 1111")), [5; 15]) %%Test input validation %!error bin2dec ()