# Differences

This shows you the differences between two versions of the page.

Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||

syntax:arith_expr [2012/11/02 17:51] techlivezheng [Arithmetic expressions] |
syntax:arith_expr [2013/04/19 18:49] thebonsai [Arithmetic expressions] change link to Greg's wiki, thanks Joan |
||
---|---|---|---|

Line 15: | Line 15: | ||

These expressions are evaluated following some rules described below. The operators and rules of arithmetic expressions are mainly derived from the C programming language. | These expressions are evaluated following some rules described below. The operators and rules of arithmetic expressions are mainly derived from the C programming language. | ||

- | This article describes the theory of the used syntax and the behaviour. To get practical examples without big explanations, see [[http://wooledge.org/mywiki/ArithmeticExpression | the article on Greg's wiki]]. | + | This article describes the theory of the used syntax and the behaviour. To get practical examples without big explanations, see [[http://mywiki.wooledge.org/BashGuide/CompoundCommands#Arithmetic_Evaluation | this page on Greg's wiki]]. |

===== Constants ===== | ===== Constants ===== | ||

Line 205: | Line 205: | ||

Bash's overall language construct is based on exit codes or return codes of commands or functions to be executed. ''if'' statements, ''while'' loops, etc., they all take the return codes of commands as conditions. | Bash's overall language construct is based on exit codes or return codes of commands or functions to be executed. ''if'' statements, ''while'' loops, etc., they all take the return codes of commands as conditions. | ||

- | Now the problem is: The return codes (0 means "TRUE" or "SUCCESS", not 0 means "FALSE" or "FAILURE") don't correspond to the meaning of the result of an arithmetic expression (0 means "TRUE", not 0 means "FALSE"). | + | Now the problem is: The return codes (0 means "TRUE" or "SUCCESS", not 0 means "FALSE" or "FAILURE") don't correspond to the meaning of the result of an arithmetic expression (0 means "FALSE", not 0 means "TRUE"). |

That's why all commands and keywords that do arithmetic operations attempt to **translate** the arithmetical meaning into an equivalent return code. This simply means: | That's why all commands and keywords that do arithmetic operations attempt to **translate** the arithmetical meaning into an equivalent return code. This simply means: |