From: Boon van der RJ Newsgroups: comp.os.msdos.djgpp Subject: Re: Help - Floating Point Exception Date: 25 Sep 1998 11:33:25 GMT Organization: Fac. Wiskunde & Informatica, VU, Amsterdam Lines: 46 Message-ID: <6ufv25$a6e$1@star.cs.vu.nl> References: NNTP-Posting-Host: sloep03.cs.vu.nl User-Agent: tin/pre-1.4-980730 (UNIX) (SunOS/5.5.1 (sun4u)) Originator: rjvdboon AT sloep03 DOT cs DOT vu DOT nl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Eneko Lacunza wrote: > I'm having some problems with the following code: > === Cut === > #define pi 3.1415926535897932385 > void build_table(void) > { > unsigned short xcont,ycont; > float radio,angulo; > for(ycont=0;ycont<200;ycont++) > for(xcont=0;xcont<320;xcont++) > { > radio=sqrt((xcont-160)*(xcont-160)+(100-ycont)*(100-ycont)); > angulo=atan2((xcont-160),(100-ycont)); atan2(0,0) might be handled not quite right, so that > table[xcont][ycont][0]=floor(radio); > table[xcont][ycont][1]=floor(255*angulo/(2*pi)); // FPE floor crashes. > } > } > This crashes at the point noted as //FPE with a Floating Point > exception. This is quite tricky, because it doesn't crash in a shell (i.e. > running it under rhide) and if I try to redir the crash, redir crashes when > the program has finished the above code and is doing something else. In a dos-box under windows 95, you can mark the screen and paste in a text-file, maybe that helps. > Could somebody tell me what does that exception mean, and how could I Perhaps devide by zero. > fix it (if this info is enough). I'm using GCC 2.7.2... Do you compile with -lm, or do you use the standards in libc? libm does some more checking (if I've understood correctly) What type of computer do you use? (386/486/pentiumII?) hth, Robert. -- rjvdboon AT cs DOT vu DOT nl | "En dat is niet waar!" sprak ex-Staatsecretaris- www.cs.vu.nl/~rjvdboon | van-Onderwijs Netelenbos fel.