From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20456 invoked by alias); 10 Jan 2015 07:27:29 -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: 34205 Received: (qmail 24878 invoked from network); 10 Jan 2015 07:27:17 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Authority-Analysis: v=2.1 cv=T/C1EZ6Q c=1 sm=1 tr=0 a=U8x73H08pUQ9rBATJ7Nnpg==:117 a=U8x73H08pUQ9rBATJ7Nnpg==:17 a=Hpgzp-inWqAA:10 a=IkcTkHD0fZMA:10 a=m_UCEknnsLD60P1iyQgA:9 a=QEXdDO2ut3YA:10 Message-id: <54B0D451.1000502@eastlink.ca> Date: Fri, 09 Jan 2015 23:27:13 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-version: 1.0 To: zsh-workers@zsh.org Subject: Re: Math expression evaluation error? References: <54B03024.1030309@gmail.com> <20150109201552.1304eafe@ntlworld.com> <54B04ADA.9050102@gmail.com> <54B05407.7090303@eastlink.ca> <775A96D9-12A6-499B-8AAB-B2431F13701D@larryv.me> <54B069A9.2040504@eastlink.ca> In-reply-to: Content-type: text/plain; charset=utf-8; format=flowed Content-transfer-encoding: 7bit On 01/09/2015 04:25 PM, Bart Schaefer wrote: > On Fri, Jan 9, 2015 at 3:52 PM, Ray Andrews wrote: >> It seems to me that if the >> shell accepts the fractions then it should return the correct answer. I'd >> make integer math the option and have accurate results as the default >> but that's just me. > > 3/8 is not a fraction. Yes, in a text paragraph like this one I might > write 3/8 as a fraction because I can't write a superscript three over > a subscript eight, but in an arithmetic expression 0.375 is a fraction > and 3/8 is "integer 3 divided by integer 8", and the definition of > "divided by" includes "if both numerator and denominator are integers, > then the result must also be an integer". As has been mentioned, this > is the way a LOT of programming languages work. Well, this is one of those things that won't change, but I must say that in my experience an overwhelming majority of people would say that 3/8 is a fraction, and they would be surprised that in zsh, by default : 1/2 + 1/2 = 0 And I'll bet they'd wonder why even though zsh is quite capable of doing floating point math, it chooses to behave like an abacus by default, other programing languages notwithstanding. Never mind, I'll just 'setopt force_float' and have accuracy. I'm glad I was forewarned about this, however. >