Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.scheme
From: scottw@bmtech.demon.co.uk (Scott Wheeler)
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!pipex!peernews.demon.co.uk!bmtech.demon.co.uk!scottw
Followup-To: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.scheme
Reply-To: Scott Wheeler <scottw@bmtech.demon.co.uk>
Subject: Re: Which first-course languages? (was: What schools use Eiffel (was: No top schools use Ada)) ?
Organization: British Maritime Technology
References: <3mq0jd$r10@kaiwan009.kaiwan.com> <NEWTNews.27781.798049024.ir001168@cec-services-01> <3mrg2c$onn@disunms.epfl.ch> <tomkwongD76x5L.AED@netcom.com> <3n33ej$2h7@theopolis.orl.mmc.com> <3n35ja$6u3@theopolis.orl.mmc.com> <jyaxda@bmtech.demon.co
X-Posting-Host: bmtech.demon.co.uk
Date: Fri, 21 Apr 1995 13:55:32 +0000
Message-ID: <jybfxn@bmtech.demon.co.uk>
Sender: usenet@demon.co.uk
Lines: 45
Xref: glinda.oz.cs.cmu.edu comp.lang.eiffel:8368 comp.lang.ada:29053 comp.edu:12182 comp.lang.scheme:12547

uk> <dewar.798388813@gnat>
X-Newsreader: NewsBase v1.36 (Beta)
Lines: 41

>> "found that they were comparing floating-point numbers for equality"
it is a common myth that this is a bad programming practice. In fact 
many numerical algorithms involve perfectly legitimate tests for 
equality if they know that they are running on reasonable 
floating-point hardware. For example, a Newton-Raphson iteration for 
square root will converge exactly on almost any reasonable fpt 
hardware.

>> It is perhaps a safe rule for people using floating-point who don't 
know what they are doing (a common case), to avoid comparing fpt 
numbers for equality, but please let's make sure that we don't end up 
with idiotic rules that forbid this critically useful operation (IEEE 
fpt includes equality for a reason, indeed all the operations defined 
by 754 are useful, you should hestitate before declarting them 
useless).

Put it this way: such a rule would be inappropriate to an applied 
mathematician studying numerical methods (although in the 
Newton-Raphson case it might still be appropriate to define an 
epsilon). A CS student will rarely use floating point, and most 
working programmers will only encounter cases where the comparison is 
unwise, so I'd say it was appropriate to teach the rule, and 
inappropriate to spend time teaching them the exceptions as the 
background required is large. But yes, it's a rule of thumb. 

Anyway, if the rule is introduced in the context of the underlying 
architecture as I asked, it shouldn't be a problem - certainly not 
idiotic. Other such items that might be introduced at the same time: 
loss of precision on subtracting f.p. numbers of similar 
magnitude; integers will "wrap around" without warning in most 
languages; some idea of how languages like Modula or C implement the 
stack and heap, introducing the idea of a stack/heap collision and the 
need to be aware of roughly how large your stack could grow; 
requirements for recusion and re-entrancy; and so on. Nothing 
earth-shattering, and it need not take long to teach.

One question: what do people see as being the primary purpose of a 
first degree in CS?

Scott
Scott
