Mail Archives: djgpp/1998/04/26/04:51:43
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 -