🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.programmer
Article #113

Re: cc problem and cure: comparison among doubles can produce wrong results

#113
From: Lars Peter Fischer
Date: Tue, 03 Nov 1992 01:21
18 lines
1095 bytes
 [ Our news server has been badly broken, so I'm resending this.
   Sorry if you've seen it before. ]

>>>>> "Brian" == Brian Willoughby (BrianW@SoundS.WA.com)

Brian> 	double res = 0.0;	// default indicating no argument was specified
Brian> [...]
Brian> 	if (res)	// now I'm using: if (res != 0.0)

*Never* use explicit comparison of floating point values using "=".
You'll be hit by all kinds of rounding errors. Use "<=" and ">="
instead, i.e., test that the value is withing some interval.

/Lars
--
Lars Fischer, fischer@iesd.auc.dk | It takes an uncommon mind to think of
CS Dept., Aalborg Univ., DENMARK. | these things.  -- Calvin
Technical Details
Message-ID: <FISCHER.92Nov3012124@steiner.iesd.auc.dk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!iesd!iesd.auc.dk!fischer

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!dkuug!iesd!iesd.auc.dk!fischer
From: fischer@iesd.auc.dk (Lars Peter Fischer)
Subject: Re: cc problem and cure: comparison among doubles can produce wrong results
Message-ID: <FISCHER.92Nov3012124@steiner.iesd.auc.dk>
Sender: news@iesd.auc.dk (UseNet News)
Organization: Mathematics and Computer Science, Aalborg University
Date: 3 Nov 92 01:21:24
Lines: 19