Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!wasatch!utah-gr!uplherc!sp7040!obie!wes From: wes@obie.UUCP (Barnacle Wes) Newsgroups: comp.lang.c Subject: Re: Unnecessary Macros (was Re: Unnecessary Parenthesis) Summary: Sure there's a good way to write it! Message-ID: <207@obie.UUCP> Date: 7 Oct 88 02:20:32 GMT References: <2089@ssc-vax.UUCP> <441@kaon.uchicago.edu> <1401@devsys.oakhill.UUCP> <8590@smoke.ARPA> Organization: the Well of Souls Lines: 31 In article <8078@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: > z = square(*p++) + square(getchar()); > I dislike the original macro, but the fact remains that there is no good way > to write this in C. In article <8590@smoke.ARPA>, gwyn@smoke.ARPA (Doug Gwyn ) replies: | One wonders whether this is much of a problem. | (Note that the example is silly.) | | There have been many occasions when I've needed the sum of two squares, | but I've never felt the need for the ability to define a "square" macro | in order to compute that. This code fragment was taken from a function that calculates the true wind speed and heading based on the apparent wind speed and angle, and the speed and course of a sailboat. Note the last line: /* * Now return the true wind vector to normal coordinates. */ tw.heading = atan2(tw.ycomp, tw.xcomp); tw.speed = sqrt((tw.ycomp * tw.ycomp) + (tw.xcomp * tw.xcomp)); This seems the obvious way to perform such a calculation to me. If any of you net.c.programmers really can't stand this style, please tell me why! -- {hpda, uwmcsd1}!sp7040!obie!wes "How do you make the boat go when there's no wind?" -- Me --