|
From: David K. <da...@gn...> - 2017-11-15 00:06:20
|
Ethan Merritt <eam...@gm...> writes: > On Tue, Nov 14, 2017 at 3:13 PM, David Kastrup <da...@gn...> wrote: > >> Ethan Merritt <eam...@gm...> writes: >> >> > On Tue, Nov 14, 2017 at 1:39 PM, theozh <th...@gm...> wrote: >> >> as described in gnuplot help, gnuplot does integer divison if the >> >> dividend and the divisors are integers. >> >> As a normal user, you don't expect this >> > >> > [shrug] integer division is "normal" for most programming and >> > scripting languages. >> >> Octave: 0.50000 > > Guile: 1/2 >> awk: 0.5 >> Perl: 0.5 >> Lua: 0.5 >> Python: 0 >> bc: 0 >> Bash: 0 >> Pascal: 0.5 >> Fortran: 0 >> >> Now I'll grant you Fortran and Python. The rest either gives 0.5 or is >> not intended for floating point calculations anyway. >> > > You left out the most relevant of all. > Gnuplot is written in C and uses C language code for internal and > user-visible evaluations. The implementation is completely irrelevant for the semantics (most scripting languages are implemented in C), and Gnuplot has operators like ** eq ne . > [now I'm nit-picking...] > > Lua doesn't have integer variables, so there the question is moot. Uh what? Octave does not have integer variables either because it is intended for numerical work. As is Gnuplot. Really, it's completely irrelevant what Gnuplot is implemented in. The question is what its application domain is. The user has nothing to gain from getting some technical analogy to the implementation language as an explanation for tripping him up. C is prone to crashes due to its memory access and allocation semantics, but that does not mean that it's Gnuplot's duty to give the user ways to crash the machine. At any rate, we are talking about decisions that have managed to stick around for decades, similar to % only being permitted for integers, as if there never was a need to, say, wrap a value in the 0..2pi domain or even calculate 420.5 % 360 for the sake of degrees. The main reason appears to me to rub the users' noses in the programmers' superior knowledge of C semantics. Gnuplot does not use a C parser so there is no inherent reason to prescribe C semantics. -- David Kastrup |