From: Wojciech Galazka Newsgroups: comp.os.msdos.djgpp Subject: Re: Floating Point Exception Date: Wed, 20 Aug 1997 13:40:56 +0200 Organization: University of Warsaw Lines: 33 Message-ID: <33FAD7C8.72E7@chem.uw.edu.pl> References: <01bcabc3$a01da100$5af382c1 AT damien> <33F8549A DOT 4CB5 AT cornell DOT edu> <01bcac2d$edf69fc0$LocalHost AT damien> <33FACBA4 DOT 1DFF7DBB AT Mathematik DOT TU-Chemnitz DOT DE> NNTP-Posting-Host: animal.chem.uw.edu.pl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Robert Hoehne wrote: > > Rich Birch wrote: > > > > Here's the code that I am sure is producing the crash (remember it doesn't > > crash in Rhide) :- > > > > float Function::Result(float x) { > > float result = 0; > > for (int count = 0; count < num_results; count++) { > > if (form.Denominator[count]) //so not to divide by zero From my good old FORTRAN experience it semms that basicly it's a very bad idea to write if(!foo) when foo is a floating point number. You'd be better off writing if (abs(foo) > SOME_SMALL_VALUE) assuming abs is a function returnig the absolute value of a variable and SOME_SMALL_VALUE is something really small, say 10^(-10) Other than this the code is perfectly legal > > result += (form.Numerator[count] > > / form.Denominator[count]) > > * int_power (x, form.Power[count]); > > } > > return(result); > > } > -- Wojciech Galazka Computer Security Advisor