[Pkg-octave-devel] Bug#361982: octave-epstk: autoscale writes 1.34e-14 instead of 0

Francesco Potorti` Potorti at isti.cnr.it
Wed May 3 09:26:26 UTC 2006


>The problem is in 'escalexy.m', in line 86
>    ticOffset=(iTic-nShortTics)*signOfDelta*deltaLabel/5;
>
>values for the relevant call:
>	ticOffset =  3.0000e+04
>	iTic = 5
>	nShortTics = 3.9250
>	signOfDelta = 1
>	deltaLabel = 2000000
>
>However:
>	debug> ticOffset - 30000
>	ans =  6.9122e-11
>
>
>This non-zero values triggers a 'wrong' value for 'firstTicValue'. 
>
>Writing the statement as
>	signOfDelta*deltaLabel/5 * iTic  - ...
>	signOfDelta*deltaLabel/5 * nShortTics
>fixes it for me. However, I'm not sure whether this kind of 'fix' is
>good: it makes the code more difficult to understand and might just
>trigger problems in other cases (for example, if both numbers are
>small).

I think that the problem is elsewhere, precisely here:

122:      if vVisible & (offset>=0 | abs(currentValue)>1e-14)
123:        if abs(currentValue)<1e-14
124:          currentValue=0;
125:        end

and should be corrected like this:

--- escalexy.m~	2006-03-20 08:48:32.000000000 +0100
+++ escalexy.m	2006-05-03 11:18:25.000000000 +0200
@@ -53,10 +53,12 @@ function longTicPos=escalexy(epsFile,sid
     %autoscale
     signOfDelta=sign(startEndDiff);
     deltaLabel=eticdis(signOfDelta*startEndDiff,maxValues);
+    LabelEps=deltaLabel*1e-2;
   else
     %fixscale
     signOfDelta=sign(step);
     deltaLabel=signOfDelta*step;
+    LabelEps=deltaLabel*sqrt(eps);
   end
   if is_scalar (vForm)
     if vForm==0  
@@ -119,8 +121,8 @@ function longTicPos=escalexy(epsFile,sid
       nPos=nPos+1;
       fprintf(epsFile,ticLineForm,longTicLength);
       % value
-      if vVisible & (offset>=0 | abs(currentValue)>1e-14)
-        if abs(currentValue)<1e-14
+      if vVisible & (offset>=0 | abs(currentValue)>LabelEps)
+        if abs(currentValue)<LabelEps
           currentValue=0;
         end
         fprintf(epsFile,moveValueForm);

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 313 8091
via G. Moruzzi 1, I-56124 Pisa         Email: Potorti at isti.cnr.it
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key




More information about the Pkg-octave-devel mailing list