Unnecessary Macros (was Re: Unnecessary Parenthesis)

Doug Gwyn gwyn at smoke.ARPA
Sun Oct 9 10:39:35 AEST 1988


In article <207 at obie.UUCP> wes at 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.)



More information about the Comp.lang.c mailing list