Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25182
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Tue, 17 Jun 2008 13:38:32 +0200
- Cc: Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- In-reply-to: <20080617103829.GD5016@xxxxxxxxxxxxxxx>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>, Richard Hartmann <richih.mailinglist@xxxxxxxxx>, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080616080726.GP10734@xxxxxxxxxxxxxxxxxxx> <20080616144211.276fb0e3@pws-pc> <2d460de70806170219k12ff4cadn441b52c48bf8076f@xxxxxxxxxxxxxx> <20080617094509.GC5016@xxxxxxxxxxxxxxx> <2d460de70806170324o5a44609x9383cc2445d67dd6@xxxxxxxxxxxxxx> <20080617103829.GD5016@xxxxxxxxxxxxxxx>
On 2008-06-17 11:38:29 +0100, Stephane Chazelas wrote:
> What I meant is that ^ reminds of the /human/ (as opposed to
> /computer/) representation as it indicates that follows must be
> raised up as in 3². So, one can understand that it should follow
> the same rules (that is -3^2 should be the same as -3², even
> though that's not what POSIX decided for bc). But given that **
> has more the shape of the * operator, I'm not sure we can tell
> the same thing.
Note that in math, -(a * b) and (-a) * b are equivalent (even in
the general case of a ring), and I'd say that most people regard
- a * b more like -(a * b) than (-a) * b. So, you can't really
compare to * without confusion.
Also ** is merely a replacement for the more conventional (and
shorter) ^ when ^ can't be used (e.g. because it already has
another meaning).
Math writing asside, the fact that -3**2 and 0-3**2 return different
results is quite confusing too.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author