[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Documentation
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] Documentation |
Date: |
Tue, 9 Dec 2014 20:36:47 -0500 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, Dec 09, 2014 at 02:35:28PM -0500, Teri Price wrote:
> In section 9.1.1 of the documentation, there is an example that I think has
> a mistake.
> Here's the example:
> "
>
> i = 5
> j = atan2(i++, i *= 2)
>
> If the order of evaluation is left to right, then i first becomes 6, and
> then 12, and atan2() is called with the two arguments 6 and 12. But if the
> order of evaluation is right to left, i first becomes 10, then 11, and
> atan2() is called with the two arguments 11 and 10.
>
> "
>
> And here's what I think it should be:
>
> If the order is left to right, atan2 is called with 2 arguments 5 and 12
> because i++ has the value of 5 even though i became 6.
>
> If the order is right to left, i*=2 makes i 10 and then i++ still holds the
> value 10, so the 2 arguments would be 10 and 10.
I think you are correct. But isn't the simpler fix to replace "i++"
with "++i"? :-)
Regards,
Andy