Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: almost floating point...
- X-seq: zsh-users 974
- From: Duncan Sargeant <dunc@xxxxxxxxxxxxxxxxx>
- To: zsh <zsh-users@xxxxxxxxxxxxxxx>
- Subject: Re: almost floating point...
- Date: Sat, 16 Aug 1997 14:58:35 +0800
- In-reply-to: <9708160359.AA24903@xxxxxxxxxxxxxxxxx>; from Jose Unpingco on Fri, Aug 15, 1997 at 08:59:31PM -0700
- References: <9708160359.AA24903@xxxxxxxxxxxxxxxxx>
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/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author