From: ellson Date: Tue, 3 Oct 2006 20:23:35 +0000 (+0000) Subject: improve arithmetic limit fix X-Git-Tag: LAST_LIBGRAPH~32^2~5840 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a246eef318f063949bc700dc3e2aa3b8dac0b93;p=graphviz improve arithmetic limit fix --- diff --git a/lib/common/geom.c b/lib/common/geom.c index 0c4bb3b05..a76e02686 100644 --- a/lib/common/geom.c +++ b/lib/common/geom.c @@ -527,6 +527,7 @@ double ptToLine2 (pointf a, pointf b, pointf p) double dx = b.x-a.x; double dy = b.y-a.y; double a2 = (p.y-a.y)*dx - (p.x-a.x)*dy; - if (a2 < .00001) return 0.; - return (a2*a2) / (dx*dx + dy*dy); + a2 *= a2; /* square - ensures that it is positive */ + if (a2 < .00001) return 0.; /* avoid 0/0 problems */ + return a2 / (dx*dx + dy*dy); }