# HG changeset patch # User jwe # Date 1192034476 0 # Node ID 6d0d8d6215321195af6866a9d4586569266706d8 # Parent 9861dc5f382b392e7aa21e24bae785fc3f099ada [project @ 2007-10-10 16:41:16 by jwe] diff -r 9861dc5f382b -r 6d0d8d621532 scripts/ChangeLog --- a/scripts/ChangeLog Wed Oct 10 00:39:22 2007 +0000 +++ b/scripts/ChangeLog Wed Oct 10 16:41:16 2007 +0000 @@ -1,3 +1,8 @@ +2007-10-10 John W. Eaton + + * general/num2str.m: Always allow for sign for automatically + computed format widths. + 2007-10-09 David Bateman * plot/patch.m: Accept a handle as the first argument. diff -r 9861dc5f382b -r 6d0d8d621532 scripts/general/num2str.m --- a/scripts/general/num2str.m Wed Oct 10 00:39:22 2007 +0000 +++ b/scripts/general/num2str.m Wed Oct 10 16:41:16 2007 +0000 @@ -53,8 +53,12 @@ else ## Setup a suitable format string if (isnumeric (x) && round (x) == x && abs (x) < 1e10) - dgt1 = ceil (log10 (max (max (abs (real (x(:)))), - max (abs (imag (x(:))))))) + 1; + if (max (abs (real (x(:)))) == 0) + dgt1 = 2; + else + dgt1 = ceil (log10 (max (max (abs (real (x(:)))), + max (abs (imag (x(:))))))) + 2; + endif dgt2 = dgt1 - (min (real (x(:))) >= 0); if (length (abs (x) == x) > 0) @@ -121,9 +125,9 @@ else if (isnumeric (x) && round (x) == x && abs (x) < 1e10) if (max (abs (x(:))) == 0) - dgt = 1; + dgt = 2; else - dgt = floor (log10 (max (abs(x(:))))) + (min (real (x(:))) < 0) + 1; + dgt = floor (log10 (max (abs(x(:))))) + (min (real (x(:))) < 0) + 2; endif if (length (abs (x) == x) > 0) fmt = sprintf ("%%%dg ", dgt);