Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25157
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Mon, 16 Jun 2008 10:07:26 +0200
- In-reply-to: <20080612095723.GF5113@xxxxxxxxxxxxxxx>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx>
Speaking of precedence, the following one is nasty:
vin% zsh -c 'echo $((-3**2))'
9
vin% bash -c 'echo $((-3**2))'
9
vin% ksh93 -c 'echo $((-3**2))'
9
IMHO these shells should be fixed to give -9, i.e. ** should have
the precedence over the unary -, like conventional math writing.
Nowadays most modern software does it right, the main exception
being MS Excel and other spreadsheet software that mimics its
behavior (current versions of OpenOffice and Gnumeric, despite
the users' complaints).
See http://www.macnauchtan.com/pub/precedence.html for the behavior
of various software on that. This page is incomplete. One can add:
Qalculate/qalc, calc, wcalc, GP/PARI and MuPAD as doing it right,
ditto for the future version of Abakus (that will be released for
KDE 4).
--
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