|
From: <ds...@ch...> - 2005-09-23 16:18:08
|
> Gnuplot could even warn every time you try to use integers in > interactive interpreted mode: > ---- > gnuplot> print 1/2 > Warning: Numeric input interpreted as integers. Consider using "set > numbermode floating" or "set numbermode integer". But only the first time integer math is used. Otherwise it would be too, um, annoying. Dan |
|
From: <ds...@ch...> - 2005-09-23 21:24:28
|
> > From: Juergen Wieferink <wie...@fr...> > Date: 2005/09/23 Fri PM 03:02:15 EDT > To: gnu...@li... > Subject: Re: gnuplot cvs source bug > > On Friday 23 September 2005 20:34 Ethan Merritt wrote: > > I happen to disagree. Integer arithmetic is quite useful in many > > contexts, and it is a standard part of programming languages and > > natural languages. Adding peculiar arithmetic operators to indicate > > that a number is an integer strikes me as being an obfuscation, not > > a clarification. Sure, sometimes even an experienced user will > > forget, and mistype (n/2) where it should have been (n/2.0). > > But also people type "if (a = b)" where it should have been > > "if (a == b)" or "if (a eq b)". Hiding this useful distinction > > in a choice of operators is not likely to reduce the number of > > mistakes. > > I would agree if variables in gnuplot had explicit types. But the > type is part of the value. In a script it can be hard or even > impossible to say if an expression "a/b" is integer or floating > point division. So an additional operator would make the code more > readable. > > I just wanted to make my point clear. I'm aware that this is > unlikly to be included. Nothing Ethan said seems to rule out the "treat all numbers as floats"/"treat non-decimal point numbers as ints" variable that someone else suggested. It is something that could be put in the gnuplot startup file for those who want gnuplot always to treat numbers as floats even immediately after launch. But yeah, int(...) of this and float(...) of that scatter about the scripts is nasty and unnecessary. Dan |
|
From: Juergen W. <wie...@fr...> - 2005-09-24 11:36:34
|
On Friday 23 September 2005 23:24 ds...@ch... wrote: > Nothing Ethan said seems to rule out the "treat all numbers as > floats"/"treat non-decimal point numbers as ints" variable that someone > else suggested. It is something that could be put in the gnuplot startup > file for those who want gnuplot always to treat numbers as floats even > immediately after launch. Such settings tend to be forgotten. So scripts get unportable for nonobvious reasons. And---probably worse---support in these questions becomes more difficult. > But yeah, int(...) of this and float(...) of that scatter about the scripts > is nasty and unnecessary. ACK. Juergen |
|
From: Robert H. <en...@no...> - 2005-09-24 12:43:39
|
On Fri, 2005-09-23 at 17:24 -0400, ds...@ch... wrote: > But yeah, int(...) of this and float(...) of that scatter about the scripts is nasty and unnecessary. You say "scatter about the scripts" like there are lots of occasions that an integer result would be required. This seems to be a matter of personal taste, but I think being explicit like that is much more obvious than going with the presence/absence of a .0 after a numeric literal. Rob -- 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. |
|
From: <ds...@ch...> - 2005-09-24 20:58:34
|
> On Fri, 2005-09-23 at 17:24 -0400, ds...@ch... wrote: > > > But yeah, int(...) of this and float(...) of that scatter about the scripts is nasty and unnecessary. > > You say "scatter about the scripts" like there are lots of occasions > that an integer result would be required. Scattered doesn't mean a lot, it means occassional occurrence here and there--rare to the point of easily overlooking. (In principle no different than having decimal points scattered about.) > This seems to be a matter of personal taste, Not taste, but convenience. I admit I don't use integer math in gnuplot right now, but I do work in a field where integer math is common, e.g., sample rates, filtering, etc. What I'm saying is don't toss out the integer math behavior. I could imagine someone using it... > but I think being explicit > like that is much more obvious than going with the presence/absence of > a .0 after a numeric literal. ... but I agree that treating all numbers as floats is probably more common. My vote would be to keep the integer mechanism with the option of casting everything to floats via "treat_all_numbers_as_floats" variable, which is on by default. Dan |