Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!uwm.edu!rutgers!bpa!cbmvax!mitchell From: mitchell@cbmvax.commodore.com (Fred Mitchell - PA) Newsgroups: comp.graphics Subject: Re: Integral Square Root Message-ID: <9175@cbmvax.commodore.com> Date: 31 Dec 89 02:32:13 GMT References: <9170@cbmvax.commodore.com> <21550@mimsy.umd.edu> Reply-To: mitchell@cbmvax.commodore.com (Fred Mitchell - PA) Organization: Commodore, West Chester, PA Lines: 54 In article <21550@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: >In article <9170@cbmvax.commodore.com> mitchell@cbmvax.commodore.com >(Fred Mitchell - PA) writes: >>Here's one that is short, fast, and sweet. > >... and wrong: the line > > if ( (rb = r+(b=1< >uses and sets rb in an unknown order. (Mr. Mitchell's compiler clearly >does the assignment, then the evaluation of the second `rb', then the >multiplication, but a compiler is free to evaluate the second `rb', then >compute r+..., assign that to rb, multiply that by the old value of rb, >and compare with n.) The simplest fix is to break up the three embedded >statements (b=, rb=, if...), which also leads to more easily understood >code. NOT WRONG- Let's analyze this line more closely (exploded IF, here we come!)... if ( ( rb = r + (b=1<In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) >Domain: chris@cs.umd.edu Path: uunet!mimsy!chris -Mitchell mitchell@cbmvax.UUCP "What do you mean I'm wrong? I've been doing this stuff for twelve years!!!" - Yours Truly.