Re: bug in division

Thomas Sefzick <[email protected]> Wed, 20 Oct 2010 09:02:59 -0700 (PDT)
Newsgroups gmane.comp.graphics.gnuplot.bugs
Message-ID <[email protected]>
the problem is 'integer division':

V=2
L=20
print V/L
V=2.
print V/L


Philipp Krüger-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello!
> 
> I just downloaded gnuplot 4.4 patchlevel 2 and am having the following
> weird problem: I have two variables V=2 and L=20 and if I try to divide
> V by L, the result is 0. I had to pick the whole script apart until I
> found it - the desired outcome of this command is of course the output
> 0.1.
> 
> Here is the script:
> #######
> set terminal png transparent size 1200,800 enhanced
> set xtics 0.1
> set grid xtics ytics mxtics mytics
> set output 'U_vs_s.png'
> set key left top
> set key box linestyle 1
> set xlabel 's'
> set ylabel 'U(s)'
> 
> # Halfwidth of strip in m
> a=2
> # Strip width in m
> w=2*a
> # Strip thickness in m
> d=2e-3
> #Voltage in V
> V=2
> # Width of simulation box in m
> L=20
> # Speed of light in m/s
> c=2.99792458e8
> # Permeability constant
> mu0=4*pi*1e-7
> # Permittivity
> eps0=1/(mu0*(c**2))
> 
> # ANSYS fitting
> Kx=pi*(V/L)*eps0
> KCorrX=7.293e-3
> y1=(8*(c**2))
> y2=(w*d)
> y3=V/L # Here this strange error occurs
> set label 'y1=%10.5e',y1 at graph 0.01, graph 0.87
> set label 'y2=%10.5e',y2 at graph 0.01, graph 0.84
> set label 'y3=%10.5e',y3 at graph 0.01, graph 0.81
> # the former line outputs "y3=0.00000e+000"
> #Ky=y1/y2
> KCorrY=1.413
> 
> plot 'Uac.dat' using ($1):($3) title 'data' w p 1
> #######
> 
> Is this indeed a bug or am I doing something exceptionally stupid?
> 
> Thanks in advance for looking into the matter.
> 
> Kind regards,
> 
> P. Krüger
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.12 (MingW32)
> 
> iQEcBAEBAgAGBQJMvuY1AAoJENDaZdRSuBW1MAgH+wfFxs5J8G1qyU+7qMUkvVOH
> Jef63XeZ0+MgRaN4yjV3ye6N/2IaT7cfj26IR71/4/mzehusoJvvM3ukl0ZEg1Sz
> znYMo3a6+bz6BoEi1lkPeAGnsjjtNcMdcJ7DlI5A8eYqN13jIf16yy4E0aWm+lXh
> vcCscYbH/I+8FIA/nAyq+e6Eig+BTvAMhC73NOWOj3qa3AO7YXYYQOMmZmv/dZet
> aFLov3P4WUbAi7+0/sWAOlUqbQBumHi1mvUpOvCmP6c/U99pmIeX3SSPt+niCRXv
> 2628lOUvB0ROi94T1HICulwy3o0MsKsFxJ1Xd5G9ryoSoH1X/q9d7xcvBoGFzLw=
> =E2Uo
> -----END PGP SIGNATURE-----
> 
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> gnuplot-bugs mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gnuplot-bugs
> 
> 

-- 
View this message in context: http://old.nabble.com/-Gnuplot-bugs--bug-in-division-tp30009548p30011407.html
Sent from the Gnuplot - Bugs mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
gnuplot-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gnuplot-bugs