|
From: Tait <gnu...@t4...> - 2017-11-15 00:37:07
|
> >> 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. > > Arguably Octave is the most relevantly similar in scope. It's worth mentioning that Python has changed this behavior. In Python2, division defaults to integer-division and 1/2 is 0. Starting with Python3 (which in my experience is used everywhere except niche applications by now) "true" division applies, meaning types are auto-promoted such that 1/2 is 0.5. I'd say integer division is gradually becoming an anachronism, and the new trend seems to be not just fixed floating-point but full rational-number support or arbitrary- (even infinite-) precision calculations, to avoid frustrating behaviors like ceil(900e-7/12e-7) => 76. |