From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13319 invoked by alias); 9 Jan 2015 20:21:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34188 Received: (qmail 27734 invoked from network); 9 Jan 2015 20:21:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Originating-IP: [86.6.153.127] X-Spam: 0 X-Authority: v=2.1 cv=AoZg3YNP c=1 sm=1 tr=0 a=39NrsSuza2clQiZR/7fYWQ==:117 a=39NrsSuza2clQiZR/7fYWQ==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=pGLkceISAAAA:8 a=RNwlxmsfKCFV2YO8-XAA:9 a=CjuIK1q_8ugA:10 Date: Fri, 9 Jan 2015 20:15:52 +0000 From: Peter Stephenson To: jdh , zsh-workers@zsh.org Subject: Re: Math expression evaluation error? Message-ID: <20150109201552.1304eafe@ntlworld.com> In-Reply-To: <54B03024.1030309@gmail.com> References: <54B03024.1030309@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 09 Jan 2015 11:46:44 -0800 jdh wrote: > I believe I read that math expression evaluation will convert all > calculations in an expression if "any" value in that expression is a > real value. This isn't the case and wherever this came from needs correcting. Please instead read the documentation under ARITHMETIC EVALUATION in the zshmisc manual for what actually happens and let us if know if you think that is inadequate. The actually phrasing is "Promotion of integer to floating point values is performed where necessary". It also refers above that to C --- there's an underlying assumption here that the user has some idea of the operation of C-like languages, which might of course not be the case. "Where necessary" is in general where an operator has a floating point number as one argument and an integer as another; a C programmer would recognise the use of the word "promotion" as implying this, a general user probably not. So the wording could probably be improved. Brief and to the point suggestions on this from anyone are welcome (long rambles on why anyone doesn't understand it may be invigorating for the rambler but are less useful to us as developers :-)). See also the following shell option: FORCE_FLOAT Constants in arithmetic evaluation will be treated as floating point even without the use of a decimal point. Integers in any base will be converted. This is most useful in zcalc, which actually has an option for this. If the option `-f' is set, all numbers are treated as floating point, hence for example the expression `3/4' evaluates to 0.75 rather than 0. Options must appear in separate words. pws