Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arithmetic operator precedence
- X-seq: zsh-workers 25178
- From: "Richard Hartmann" <richih.mailinglist@xxxxxxxxx>
- To: "Richard Hartmann" <richih.mailinglist@xxxxxxxxx>, "Peter Stephenson" <p.w.stephenson@xxxxxxxxxxxx>, "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: arithmetic operator precedence
- Date: Tue, 17 Jun 2008 12:45:03 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=P9a5zPFkQkCkFAZfJNlLekUEEd4MqXNN3rmeie2DHhg=; b=KclLzesAsARxGju3BZUtkRsW+zFTGb0dKVGWmYyRASlp8R1FqIXLn/AwVfaYoe30qr W34KUi5g3OSv38svnX1RmY9/JxPJjhq8WVXmeNCwqA4mHQmzahQ7yjpdeFHs4kBWtwoL tg8YvreKTKLFe6jKkK0oskO0BEXP8ZCse7m0Y=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=F3p6QjpLxqQ3fS4faLlPiL0dOGxMvrcJ2/jzl1uYdQz6hzD2tNwNSrUkAAqoBjV1sJ QCpwcV99SfV2dlPHr2XlZSI5SYDSlKongdPUv2tjjHP7ak4eqvisgHvQDPX26Q28Ut08 Ziq1ScRdzuPzZzoj6oACKnpMPRRl7TC34gC/I=
- In-reply-to: <20080617103829.GD5016@xxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20080612095723.GF5113@xxxxxxxxxxxxxxx> <20080616080726.GP10734@xxxxxxxxxxxxxxxxxxx> <20080616144211.276fb0e3@pws-pc> <2d460de70806170219k12ff4cadn441b52c48bf8076f@xxxxxxxxxxxxxx> <20080617094509.GC5016@xxxxxxxxxxxxxxx> <2d460de70806170324o5a44609x9383cc2445d67dd6@xxxxxxxxxxxxxx> <20080617103829.GD5016@xxxxxxxxxxxxxxx>
On Tue, Jun 17, 2008 at 12:38, Stephane Chazelas
<Stephane_Chazelas@xxxxxxxx> wrote:
> Not sure what you mean. ^ in bc is the power operator and
> there's no ** there. In shells, ** is the power operator and ^
> is the XOR operator.
I did not refer to the XOR interpretation of ^, of course.
What I thought you said is that ^ and ** as in
3^2 = 9
3**2 = 9
are not the same. Did not make sense to me, but did not want
to discard the idea entirely without checking.
> What I meant is that ^ reminds of the /human/ (as opposed to
> /computer/) representation as it indicates that follows must be
> raised up as in 3². So, one can understand that it should follow
> the same rules (that is -3^2 should be the same as -3², even
> though that's not what POSIX decided for bc). But given that **
> has more the shape of the * operator, I'm not sure we can tell
> the same thing.
I can see what you mean, but the operator, not its representation,
must be must stay the same. Do I understand you correctly that
you think this is the way to go:
-3^2 = -9
-3**2 = 9
If yes, that looks _really_ harmful to me.
> Anyway, I was just curious about Peter's statement. I'm most
> probably not as versed in maths as he is, so was curious about
> the rationale behind his statement about -3**2 = 9 not being
> mathematically correct.
See above for my question, requesting clarification.
Richard
Messages sorted by:
Reverse Date,
Date,
Thread,
Author