www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/31/08:31:08

From: "Alan Carter" <alanc AT clara DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: ATAN causing FP Exception
Date: 31 Mar 1998 13:22:30 GMT
Lines: 39
Message-ID: <01bd5ca7$c0918ce0$395008c3@alan>
NNTP-Posting-Host: 195.8.80.57
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi fellas,

I have this code which is causing me problems, it used
to work just fine in Watcom, and VC doesnt mind it either,
but DJGPP exits at random when it comes across the
offending line.  Apologies for the state of the code, ive
been tinkering with assignments etc to try and get it to 
work.  Any help, ideas, suggestions would be gratefully
welcomed!

float get_ang(int x1,int y1,int x2,int y2)
{
    // return angle between 2 points in degs

    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
		  // the exception

    sub=(sub/3.14152)*180;

    ang=sub;
    if(x1<x2)
    {
        if(y1<y2) return 180-ang; else return ang;
    }
    else
    {
        if(y1<y2) return 180+ang; else return 360-ang;
    }
}

thanks guys :)

- Raw text -


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