|
From: Robert H. <en...@no...> - 2005-09-23 13:12:51
|
On Fri, 2005-09-23 at 14:57 +0200, Hans-Bernhard Broeker wrote: > Well, you don't have a computer with a mind-reading interface, do you? > So how do you expect it to be able to know what you *think*, > particularly in a case like this where what you think openly disagrees > with what you actually told it via keyboard? Do you actually believe that? Even if you are a C programmer, and you understand why there is a distinction between 2/3 and 2.0/3.0 this must still catch you out time and time again? Thankfully in this case the symptoms are strong enough that the error is easily noticed, and therefor fixed, but it's also easy to get caught out in more subtle ways too. i.e. with larger integers. It's even worse that although we use the C convention of integer division but also have implicitly typed variables, something like this is wrong too: f(x) = 1/a*x a = 5 plot f(x) a = 5.0 plot f(x) 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? -- 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. |