Date: Sun, 27 Dec 1998 14:37:30 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Nate Eldredge , Mad Cow cc: djgpp AT delorie DOT com Subject: Re: StarMaps In-Reply-To: <36856D22.9F3965BF@cartsys.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com On Sat, 26 Dec 1998, Nate Eldredge wrote: > double distance(double x1, double y1, double x2, double y2) > { > return sqrt(SQ(x1-x2) + SQ(y1-y2)); > } Note that there's a library function called `hypot' that would do this for you, and avoid some common cases of over- and under-flow while at that. Also, a word of advice: unless you *absolutely* __have to__, do NOT compute the square root; use the squared distance instead. sqrt is slow in most cases, and should be avoided unless you can't. For example, if you need the distance to compare two distances, compare the squared distances instead.