delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/23/13:01:58

From: Fabrice ILPONSE <fabrice AT asim DOT lip6 DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: (none)
Date: Thu, 23 Apr 1998 18:47:45 +0200
Organization: Universites Paris VI/Paris VII - France
Lines: 39
Message-ID: <353F70B1.8BF02D6@asim.lip6.fr>
References: <3 DOT 0 DOT 3 DOT 32 DOT 19980423122620 DOT 0068f068 AT ns DOT coba DOT net>
NNTP-Posting-Host: asim.lip6.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Daniel Delorme wrote:
> 
> I have this problem with SIGFPE...
> 
> double DistanceBetweenPoints(strPOINT *Pt1, strPOINT *Pt2)
> {
>   double Dist;
> 
>   Dist = pow(fixtof(Pt1->X - Pt2->X), 2)+
>          pow(fixtof(Pt1->X - Pt2->X), 2)+
>          pow(fixtof(Pt1->X - Pt2->X), 2);
>   Dist = sqrt(Dist);
>   printf("Dist = %f\n", Dist);  <----- program crashes here with SIGFPE
> }
> 
> traceback:
> _doprnt+3548
> _doprnt+1574
> printf+20
> DistanceBetweenPoints
> 
> and I #included math.h
> 
> Why would SIGFPE appear in a mere printf ?
> What causes SIGFPE anyway ?
> If I remove the printf, I get SIGFPE at "if (Dist1[I] <= Dist2[J])"
>   (Dist1[6] and Dist2[6] are float)


	try to use %g or %G instead of %f.

-- 
	^ ^ ^
	| | |
	+-+-+	Fabrice ILPONSE
	  |	email: fabrice AT asim DOT lip6 DOT fr
	  |
	  |
	  -

- Raw text -


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