www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/01/03:25:45

Date: Wed, 1 Apr 1998 11:22:49 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Alan Carter <alanc AT clara DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: ATAN causing FP Exception
In-Reply-To: <01bd5ca7$c0918ce0$395008c3@alan>
Message-ID: <Pine.SUN.3.91.980401112043.2919H-100000@is>
MIME-Version: 1.0

On 31 Mar 1998, Alan Carter wrote:

>     float xlen,ylen,ang,res,sub;
>     res=sub=xlen=ylen=ang=0;
> 
>     xlen=fabs(x1-x2);
>     ylen=fabs(y1-y2);
> 
>     res=xlen/ylen;
> 
>     sub=atan(res); // << -- this is the little bugger causing

You pass a float argument to `atan', which expects a double.  GCC will 
perform the conversion for you, but only if your source file says 
#include <math.h> somewhere.  If you didn't do that, that's why it 
crashes.

Also, it's a good idea to use the -Wall switch to GCC, it will catch many 
such bugs in embryo.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019