Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25172
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Richard Hartmann <richih.mailinglist@xxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Tue, 17 Jun 2008 10:45:09 +0100
- Cc: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxxxxx>
- In-reply-to: <2d460de70806170219k12ff4cadn441b52c48bf8076f@xxxxxxxxxxxxxx>
- Mail-followup-to: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080616080726.GP10734@xxxxxxxxxxxxxxxxxxx> <20080616144211.276fb0e3@pws-pc> <2d460de70806170219k12ff4cadn441b52c48bf8076f@xxxxxxxxxxxxxx>
On Tue, Jun 17, 2008 at 11:19:40AM +0200, Richard Hartmann wrote:
[...]
> > That's an interesting point for C_PRECEDENCES since I was trying to get
> > it behave as much as possible like Perl. What does anyone else think?
>
> Being unsure myself, I did some somewhat extensive research. The only
> mathematically correct way of doing this is
>
> -3**2 = -9
> (-3)**2 = 9
[...]
In which way is it more "mathematically" correct?
Is that because -3² is -9?
But ** is not ^, it's a binary operator whose shape reminds that
of multiply, like a multiply++. And even then, POSIX's ^ in bc
is handled as -3^2 = 9.
It could be a good idea to ask ksh, POSIX/bc and perl authors for
the rationale behind their choices.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author