Mercurial > hg > octave-thorsten
changeset 4918:d2a7208f35d4
[project @ 2004-07-27 15:18:04 by jwe]
author | jwe |
---|---|
date | Tue, 27 Jul 2004 15:18:04 +0000 |
parents | f69e95587ba3 |
children | a1073eef650c |
files | scripts/ChangeLog scripts/general/num2str.m |
diffstat | 2 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2004-07-27 David Bateman <dbateman@free.fr> + + * general/num2str.m: Also insert spaces in output when precision + argument is supplied. + 2004-07-23 David Bateman <dbateman@free.fr> * general/bitcmp.m, general/bitget.m, general/bitset.m: New functions.
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -44,7 +44,11 @@ if (isstr (arg)) fmt = strcat (arg, "%-+", arg(2:end), "i"); else - fmt = sprintf ("%%.%dg%%-+.%dgi", arg); + if (isnumeric (x) && round (x) == x && abs (x) < (10.^arg)) + fmt = sprintf ("%%%dd%%-+%ddi ", arg, arg); + else + fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg); + endif endif else ## Setup a suitable format string @@ -103,7 +107,11 @@ if (isstr (arg)) fmt = arg; else - fmt = sprintf ("%%.%dg", arg); + if (isnumeric (x) && round (x) == x && abs (x) < (10.^ arg)) + fmt = sprintf ("%%%dd ", arg); + else + fmt = sprintf ("%%%d.%dg", arg+7, arg); + endif endif else if (isnumeric (x) && round (x) == x && abs (x) < 1e10)