[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
operator precedence confusion
From: |
Mike McClain |
Subject: |
operator precedence confusion |
Date: |
Mon, 29 Apr 2024 14:43:32 -0500 |
$ help let says:
The following list of operators is grouped into levels of equal-precedence
operators.
The levels are listed in order of decreasing precedence.
id++, id-- variable post-increment, post-decrement
++id, --id variable pre-increment, pre-decrement
-, + unary minus, plus
!, ~ logical and bitwise negation
** exponentiation
*, /, % multiplication, division, remainder
.
.
.
Hence plus(+) has higher precedence than multiplication(*).
Yet
$ let n=$[1+2*3]; echo $n;
7
or
$ echo $[1+2*3]
7
Shows that multiplication(*) is executed/interpreted before plus(+).
Herein lies my confusion and an explanation would be appreciated.
Thanks,
Mike
--
"Change is not necessary if survival is not mandatory."
- 'American Bee Journal' Nov. 2019
- operator precedence confusion,
Mike McClain <=