- 论坛徽章:
- 8
|
- ARITHMETIC EVALUATION
- The shell allows arithmetic expressions to be evaluated, under certain
- circumstances (see the let and declare builtin commands and Arithmetic
- Expansion). Evaluation is done in fixed-width integers with no check
- for overflow, though division by 0 is trapped and flagged as an error.
- The operators and their precedence, associativity, and values are the
- same as in the C language. 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 and post-decrement
- ++id --id
- variable pre-increment and pre-decrement
- - + unary minus and plus
- ! ~ logical and bitwise negation
- ** exponentiation
- * / % multiplication, division, remainder
- + - addition, subtraction
- << >> left and right bitwise shifts
- <= >= < >
- comparison
- == != equality and inequality
- & bitwise AND
- ^ bitwise exclusive OR
- | bitwise OR
- && logical AND
- || logical OR
- expr?expr:expr
- conditional operator
- = *= /= %= += -= <<= >>= &= ^= |=
- assignment
- expr1 , expr2
- comma
复制代码 |
|