From bug-request at octave dot org Tue Nov 22 21:58:25 2005 Subject: axis rounding From: "John W. Eaton" To: hwz at hwz dot bv dot TU-Berlin dot DE Cc: bug at octave dot org Date: Tue, 22 Nov 2005 22:56:21 -0500 On 22-Nov-2005, hwz at hwz dot bv dot TU-Berlin dot DE wrote: | I found that the axis-command introduces a large roundoff problem | when using large values as limits because of the g-format statement | in axis.m, e.g. | | if (len > 1) | __gnuplot_raw__ (sprintf ("set xrange [%g:%g];\n", ax(1), ax(2))); | endif | | This lead to problems, if one likes to scale exactly | Here is an example: | | octave:17> y1 = 979923450; | octave:18> y2 = 979923750; | octave:19> sprintf ("set xrange [%g:%g];\n", y1, y2) | ans = set xrange [9.79923e+08:9.79924e+08]; | | is not what i need (cutting 979923450 to 979923000!), but | | octave:20> sprintf ("set xrange [%20.15g:%20.15g];\n", y1, y2) | ans = set xrange [ 979923450: 979923750]; | | does the job right. | Therefore I'd suggest to change the format to %20.15g (or similar) | to ensure to send all significant digits to gnuplot. OK, I used %.16g instead (I don't think there is a need to set the minimum overall field width here, but maybe I'm missing something). jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------