Deutsch   English   Français   Italiano  
<v2nium$1pl8f$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.awk
Subject: Operator precedence
Date: Thu, 23 May 2024 16:13:33 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <v2nium$1pl8f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 23 May 2024 16:13:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="bf116be3e1a9b97e20c69753416c3d06";
	logging-data="1889551"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+iEE8NKD4omb8m3jmV2VbK"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
Cancel-Lock: sha1:qEbXVBHzo8yad+TsTkmwmF25h/w=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
Bytes: 1517

After reading an old article in the Algol bulletin about questions
and issues with operator precedences I tried this with (Gnu) Awk

$ awk 'BEGIN { a=5; print a^2, -a^2, 0-a^2 }'
25 -25 -25

and shell (Ksh)

$ a=5 ; print $(( a**2 )) $(( -a**2 )) $(( 0-a**2 ))
25 25 -25

and Algol 68

$ a68g -p 'INT a=5; (a^2, -a^2, 0-a^2)'
        +25        +25        -25

I don't want to value the different results (based on precedence),
but I'm interested in your comments/thoughts about the differences.

Janis