|
From: Robert H. <en...@no...> - 2005-09-23 14:20:16
|
On Fri, 2005-09-23 at 15:48 +0200, Hans-Bernhard Broeker wrote: > Yes, and I will until the day the first DIWM (for "do-what-I-mean") > interfaced computer becomes available --- it's been elusive for so long > that I seriously doubt it will ever happen, though. Until then we have the "principle of least surprise" - in other words a computer can be made to "DWIM" as much of the time as possible by doing what you would expect most likely it to do. Thus in the context of a scientific plotting package that primarily plots continuous functions and arbitrary discrete data, the mathematical (and human) definition of division would be expected. > > Can you actually think of a real-life case where integer maths is the > > "correct" way of doing a calculation *and* explicitly using the int() > > function would not be appropriate? > > Yes. It's quite obvious, too: integer maths has applications where > floats simply don't apply. gnuplot has binary operators like '%', '|', > '&' and '^' which are applicable only to integers. Yes, but we are talking about a situation where floats *do* apply. Surely it is more logical to treat numbers as floats *unless* they are used in a context where only integers apply. For any ambiguous case (division and exponentiation), anybody who wants the integer math *knows* they want it and can use int() Other counter-intuitive behaviour: gnuplot> print 1/(5**1) 0 gnuplot> print (5**-1) 0.2 gnuplot> x=1000000000000000000 gnuplot> print x 2147483647 gnuplot> x=1000000000000000000.0 gnuplot> print x 1e+18 gnuplot> x=1*10**18 gnuplot> print x -1486618624 -- Robert Hart <en...@no...> University of Nottingham This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. |