Description
Executes an arithmetic operation.
Synopsis
expr arg [arg arg ...]
Option
Specify the expression.
Valid operators (listed in decreasing order of precedence)
- + ~ ! | Unary minus, unary plus, complement, logical NOT |
* / % | Multiply, divide, remainder |
+ - | Add, subtract |
A part of expression enclosed in parentheses (()) takes precedence over the others included in the same command and is computed first.
Return Value
The result of operation is returned.
Example
The following example displays the result of 3 x (10 - (4 - 2)).
set result [expr 3*(10-(4-2))] puts $result
Execution Results/Output Format
24