www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/26/04:51:43

Date: Sun, 26 Apr 1998 11:49:36 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Daniel Delorme <daniel AT coba DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: your mail
In-Reply-To: <3.0.3.32.19980423122620.0068f068@ns.coba.net>
Message-ID: <Pine.SUN.3.91.980426114911.19566E-100000@is>
MIME-Version: 1.0

On Thu, 23 Apr 1998, Daniel Delorme wrote:

> 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 ?

You didn't supply enough information to help you efficiently.  Please
at least specify what are the values of all the variables involved in
the computation which causes SIGFPE.  A complete short program which
can be compiled would be even nicer.

For what it's worth, it seems to me that you have hand-typed the code
that you posted, and the actual program is different (you probably
meant to use the Y and Z members as well when computing a distance).

As an aside, using `pow' to compute a square of a number is a bad
idea; multiplying the number by itself is much faster.

- Raw text -


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