From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21213 invoked from network); 16 Aug 1997 07:15:55 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 16 Aug 1997 07:15:55 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.8.5/8.8.5) id CAA14937; Sat, 16 Aug 1997 02:59:15 -0400 (EDT) Resent-Date: Sat, 16 Aug 1997 02:58:42 -0400 (EDT) Message-ID: <19970816145835.17252@ucc.gu.uwa.edu.au> Date: Sat, 16 Aug 1997 14:58:35 +0800 From: Duncan Sargeant To: zsh Subject: Re: almost floating point... References: <9708160359.AA24903@cryptica.UCSD.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <9708160359.AA24903@cryptica.UCSD.EDU>; from Jose Unpingco on Fri, Aug 15, 1997 at 08:59:31PM -0700 Resent-Message-ID: <"VSi_s1.0.Ce3.X-Kzp"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/974 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Jose Unpingco wrote on Fri August 15, at 20:59 -0700: > I like to use the arithmetic abilities of zsh often and have noticed > that > > z=1; > echo $(( $z + 1/3*6 )) > > doesn't add 2 to 1 =3. I think the intermediate divide operation > confuses things somehow since echo $(( $z + 6*1/3 )) should do what you need. It appears * and / have the same precedence, and the / appears first, so 1/3 = 0 is computed first ... ;-) When we learnt how to use a scientific calculator in school, we were taught "BIMDAS" (Brackets, Indices, Multiplication, Division, Addition, Subtraction). In Real Life integer calculation, I've never seen a system where M & D weren't equal precedence, associating left to right. Ditto for A & S. cheers ,dunc -- Duncan Sargeant - metacitizen - http://www.ucc.gu.uwa.edu.au/~dunc/