Newsgroups: comp.os.msdos.djgpp From: Peter Berdeklis Subject: Re: Floating Point Exception Message-ID: Nntp-Posting-Host: chinook.physics.utoronto.ca Sender: news AT info DOT physics DOT utoronto DOT ca (System Administrator) Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Organization: University of Toronto - Dept. of Physics In-Reply-To: <5tspej$7gt$1@news.IAEhv.nl> Date: Wed, 27 Aug 1997 21:32:29 GMT 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> <33FAD7C8 DOT 72E7 AT chem DOT uw DOT edu DOT pl> <5tspej$7gt$1 AT news DOT IAEhv DOT nl> Lines: 25 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On 25 Aug 1997, Jos Bergervoet wrote: > There is actually no need to prevent division by zero. It should > produce Inf or Nan, and often your computation can go on and > still deliver good results. DJGPP doesn't fail on this: > > double a=1, b=0, c; > c = a/b; /* now c=Inf */ > c = 1/c; /* now c=1/Inf = 0, which is correct */ > printf( "Hello: result = %10.4g\n", c ); On an INTEL PC a divide by zero will cause a hardware exception that will cause the processor to halt. It will return Inf or NaN only if you install an exception handler that returns that value when the processor flags the exception. On some other machines (namely the SGI that I work on) the processor will return an Inf or NaN by itself, but the state of the processor is such that it will produce a steady stream of garbage afterwards. Personally I prefer a simple exception, thank you very much. --------------- Peter Berdeklis Dept. of Physics, Univ. of Toronto