Mercurial > hg > octave-nkf
comparison scripts/general/num2str.m @ 19930:5f2c0ca0ef51
Ensure that numbers passed to integer *printf format codes are integers (bug #44245).
* num2str.m, validateattributes.m, inputname.m, stemleaf.m, print.m,
__ghostscript__.m, __gnuplot_print__.m, __go_draw_axes__.m,
__go_draw_figure__.m, bicg.m, qmr.m, mat2str.m, validatestring.m, assert.m:
Ensure that numbers passed to integer *printf format codes are integers.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 16 Feb 2015 16:51:45 -0800 |
parents | 00e31f316a3a |
children | 9fc020886ae9 |
comparison
equal
deleted
inserted
replaced
19929:abc158e7122e | 19930:5f2c0ca0ef51 |
---|---|
81 retval = ""; | 81 retval = ""; |
82 elseif (isreal (x)) | 82 elseif (isreal (x)) |
83 if (nargin == 2) | 83 if (nargin == 2) |
84 if (ischar (arg)) | 84 if (ischar (arg)) |
85 fmt = arg; | 85 fmt = arg; |
86 elseif (isnumeric (arg) && isscalar (arg) && arg >= 0) | 86 elseif (isnumeric (arg) && isscalar (arg) && arg >= 0 && arg == fix (arg)) |
87 fmt = sprintf ("%%%d.%dg", arg+7, arg); | 87 fmt = sprintf ("%%%d.%dg", arg+7, arg); |
88 else | 88 else |
89 error ("num2str: PRECISION must be a scalar integer >= 0"); | 89 error ("num2str: PRECISION must be a scalar integer >= 0"); |
90 endif | 90 endif |
91 else | 91 else |
120 retval = strtrim (char (ostrsplit (tmp(1:end-1), "\n"))); | 120 retval = strtrim (char (ostrsplit (tmp(1:end-1), "\n"))); |
121 else # Complex matrix input | 121 else # Complex matrix input |
122 if (nargin == 2) | 122 if (nargin == 2) |
123 if (ischar (arg)) | 123 if (ischar (arg)) |
124 fmt = [arg "%-+" arg(2:end) "i"]; | 124 fmt = [arg "%-+" arg(2:end) "i"]; |
125 elseif (isnumeric (arg) && isscalar (arg) && arg >= 0) | 125 elseif (isnumeric (arg) && isscalar (arg) && arg >= 0 && arg == fix (arg)) |
126 fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg); | 126 fmt = sprintf ("%%%d.%dg%%-+%d.%dgi", arg+7, arg, arg+7, arg); |
127 else | 127 else |
128 error ("num2str: PRECISION must be a scalar integer >= 0"); | 128 error ("num2str: PRECISION must be a scalar integer >= 0"); |
129 endif | 129 endif |
130 else | 130 else |