Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!haven!ncifcrf!nlm-mcs!adm!smoke!gwyn From: gwyn@smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Message-ID: <8665@smoke.ARPA> Date: 9 Oct 88 00:39:35 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> <8590@smoke.ARPA> <207@obie.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 9 In article <207@obie.UUCP> wes@obie.UUCP (Barnacle Wes) writes: > tw.heading = atan2(tw.ycomp, tw.xcomp); > tw.speed = sqrt((tw.ycomp * tw.ycomp) + (tw.xcomp * tw.xcomp)); A perfect opportunity to use the hypot() function. Unfortunately X3J11 chose not to standardize it, but if it doesn't exist on some system you can easily provide one that works no worse than the explicit code given above. (A good implementation of hypot is more accurate and robust.)