[Newbies] Re: [BUG] Inconsistent float soustraction (slightly offtopic)

johnps11 at bigpond.com johnps11 at bigpond.com
Mon Feb 18 04:26:13 UTC 2008

I studied and taught at Griffith University in Australia.  At the time the
computing dept was a weird combination of Business Programmers and
Numerical Modelers.  I wouldn't be surprised if this kind of fundamental
instruction has disappeared these days, given the tendency to expose
students to Java or C# as their 1st languages.  I believe this is going to
result in a lot of 'programmers' who are good at gluing pieces together,
but have little to no clue about memory or what actually goes on in

I guess I was lucky to have learned via the Pascal > C > Machine code >
Actor (an extinct Smalltalk dialect) > FORTRAN > C++ path.  I've seen
people who started with Java do terrible things, like seeding multiple
PRNGs based on system time rounded to the second inside tight loops, then
wondering why they have identical streams of PRNs.

My 2 cents,


> I don't know which university you went to, but I certainly never observed
> any serious attempt to enforce such a rule at university. That said, it's
> a
> good one for all of us to learn if we don't apply it already.
> On Feb 17, 2008 8:56 PM, <johnps11 at bigpond.com> wrote:
>> Cedric,


>> The simplest rule is any attempt to test floats (or doubles, or IEEE
>> decwords) for equality is a bug.  If there's a decimal point in your
>> calculations (or if there could be) then don't test for equality.  This
>> is
>> taught to computing students at University in the first few weeks.  Any
>> work done by a Uni student who breaks this rule gets marked down very
>> severely!
>> I commend you on discovering this on your own by the way - it shows an
>> inquiring mind.  It's not everyone who hits one of the key issues in
>> Computer Science by themselves, and then thinks about it.
>> Yours,
>> John.


More information about the Beginners mailing list