diff scripts/strings/dec2base.m @ 5133:7191f6e086f9

[project @ 2005-02-08 19:17:41 by jwe]
author jwe
date Tue, 08 Feb 2005 19:17:41 +0000
parents 8bf86c0fad1b
children 4c8a2e4e0717
line wrap: on
line diff
--- a/scripts/strings/dec2base.m	Tue Feb 08 17:20:38 2005 +0000
+++ b/scripts/strings/dec2base.m	Tue Feb 08 19:17:41 2005 +0000
@@ -89,8 +89,13 @@
   ## convert digits to symbols
   retval = reshape (symbols (digits+1), size (digits));
 
-  ## Check if the first element is the zero symbol
-  if (all (retval(:,1) == symbols(1)))
+  ## Check if the first element is the zero symbol. It seems possible
+  ## that LEN is provided, and is less than the computed MAX_LEN and
+  ## MAX_LEN is computed to be one larger than necessary, so we would
+  ## have a leading zero to remove.  But if LEN >= MAX_LEN, we should
+  ## not remove any leading zeros.
+  if ((nargin == 2 || (nargin == 3 && max_len > len))
+      && all (retval(:,1) == symbols(1)))
     retval = retval(:,2:end);
   endif