Groups | Search | Server Info | Login | Register
Groups > comp.lang.awk > #9757
| From | Axel Reichert <mail@axel-reichert.de> |
|---|---|
| Newsgroups | comp.lang.awk |
| Subject | Re: Operator precedence |
| Date | 2024-05-25 13:34 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <87zfsektvi.fsf@axel-reichert.de> (permalink) |
| References | (1 earlier) <20240523092856.646@kylheku.com> <87sey8movv.fsf@axel-reichert.de> <v2okuh$1vrvh$1@dont-email.me> <v2ouo9$2547f$1@dont-email.me> <20240523210755.307@kylheku.com> |
Kaz Kylheku <643-408-1753@kylheku.com> writes:
> Now in the C grammar, we have multiplication also occuping a
> precedence rung between unary plus/minus and additive expressions.
>
> Thus -A*B means (-A)*B, whereas X - A*B means X-(A*B).
>
> In this case it doesn't matter because the unary minus is
> a kind of product. -A can be regarded as a shorthand for (-1)*A.
>
> More importantly the identity (-A)*B = -(A*B) holds.
>
> This creates a problem if we naively wedge exponentiation into
> the grammar, by sticking it into a precedence level above
> multiplication, but below unary.
>
> The identity does not hold in exponentiation: (-A)**B
> is not -(A**B).
Very nice explanation, many thanks. I will likely pass it to a friend
(geodesist), who had a heated argument with the math teacher of her son
about whether
2
-3
is -9 or +9. I think the mathematical conventions are clear (and
probably established for centuries), but the teacher might be confused
and think Excel is the reference, see
https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign
It would be interesting to learn about the motivation for spreadsheets
and "bc" to deviate from the mathematical convention.
Best regards
Axel
Back to comp.lang.awk | Previous | Next — Previous in thread | Next in thread | Find similar
Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-23 16:13 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-23 16:49 +0000
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-23 19:14 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-24 01:53 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-24 04:41 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-24 04:32 +0000
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-25 13:34 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-25 23:31 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-26 00:03 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-25 22:26 +0000
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 06:59 +0200
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:24 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:08 +0200
Re: Operator precedence Christian Weisgerber <naddy@mips.inka.de> - 2024-05-26 00:37 +0000
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-26 02:06 +0000
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 07:26 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-30 07:06 +0200
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:22 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:16 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-25 23:31 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-26 01:29 +0000
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-30 10:17 +0200
Re: Operator precedence Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-05-31 17:46 +0200
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-06-01 09:11 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-24 03:45 +0000
Re: Operator precedence Axel Reichert <mail@axel-reichert.de> - 2024-05-25 13:09 +0200
Re: Operator precedence Kaz Kylheku <643-408-1753@kylheku.com> - 2024-05-25 22:20 +0000
csiph-web