From: Duncan Sargeant <dunc@ucc.gu.uwa.edu.au>
To: zsh <zsh-users@math.gatech.edu>
Subject: Re: almost floating point...
Date: Sat, 16 Aug 1997 14:58:35 +0800 [thread overview]
Message-ID: <19970816145835.17252@ucc.gu.uwa.edu.au> (raw)
In-Reply-To: <9708160359.AA24903@cryptica.UCSD.EDU>; from Jose Unpingco on Fri, Aug 15, 1997 at 08:59:31PM -0700
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/
prev parent reply other threads:[~1997-08-16 7:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-08-16 3:59 Jose Unpingco
1997-08-16 6:58 ` Duncan Sargeant [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19970816145835.17252@ucc.gu.uwa.edu.au \
--to=dunc@ucc.gu.uwa.edu.au \
--cc=zsh-users@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).