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 | ||
manual:Calculations [2021/10/04 02:58] peternlewis |
manual:Calculations [2023/02/14 21:13] peternlewis |
||
---|---|---|---|
Line 25: | Line 25: | ||
| Array Separator (`,`) | Allows a text Variable, which has comma separated values, to work somewhat like an Array.\\ Assume `MyKMVariable` contains "value1,value2,value3", then `MyKMVariable[2]` returns "value2". | | | Array Separator (`,`) | Allows a text Variable, which has comma separated values, to work somewhat like an Array.\\ Assume `MyKMVariable` contains "value1,value2,value3", then `MyKMVariable[2]` returns "value2". | | ||
| Ternary Operator (`?`) | a=b ? 3 : 4 | | | Ternary Operator (`?`) | a=b ? 3 : 4 | | ||
- | | Bitwise OR (`|`), Bitwise AND (`&`) and Bitwise XOR | bitwise operators. | | + | | Bitwise OR (`|`), Bitwise AND (`&`) and Bitwise XOR | bitwise operators, which also act as logical boolean operators for 0 (false) and 1 (true). | |
| Comparison Operators (`<, ≤, =, >, ≥, ≠`) | compare for (in)equality and return 0 or 1. | | | Comparison Operators (`<, ≤, =, >, ≥, ≠`) | compare for (in)equality and return 0 or 1. | | ||
| Shift Operators (`≪, ≫`) | shift a number left or right. | | | Shift Operators (`≪, ≫`) | shift a number left or right. | | ||
- | | Arithmetic Multiplication Operators\\ • Multiply (`*`)\\ • Divide (`/`) | Basic mathematical operations. | | + | | Arithmetic Addition Operators \\ • Add (`+`)\\ • Subtract (`-`) | Basic mathematical operations. | |
- | | Arithmetic Additiona Operators\\ • Add (`+`)\\ • Subtract (`-`) | Basic mathematical operations. | | + | | Arithmetic Multiplication Operators \\ • Multiply (`*`)\\ • Divide (`/`) | Basic mathematical operations. | |
| [Modulo](https://en.wikipedia.org/wiki/Modulo_operation) (`i MOD n`) | The remainder of the division of `i` by `n`.\\ Both values (`i`, `n`) will be treated as integer.\\ `n` must not be 0.\\ the sign of the result is the same as the sign of i. | | | [Modulo](https://en.wikipedia.org/wiki/Modulo_operation) (`i MOD n`) | The remainder of the division of `i` by `n`.\\ Both values (`i`, `n`) will be treated as integer.\\ `n` must not be 0.\\ the sign of the result is the same as the sign of i. | | ||
- | | Integer division (`i DIV n`) (v9.0+)| The integer quotient of the division of `i` by `n`.\\ Both values (`i`, `n`) will be treated as integer.\\ `n` must not be 0.\\ the sign of the result matches the sign of regular division. | | + | | Integer division (`i DIV n`) | The integer quotient of the division of `i` by `n`.\\ Both values (`i`, `n`) will be treated as integer.\\ `n` must not be 0.\\ the sign of the result matches the sign of regular division. | |
| Power Operator (`^`) | exponentiation. | | | Power Operator (`^`) | exponentiation. | | ||
| Unary Prefix Operators (`√`, `-`, `( )` ) | square root, negation, sub-expressions. | | | Unary Prefix Operators (`√`, `-`, `( )` ) | square root, negation, sub-expressions. | | ||
Line 42: | Line 42: | ||
[[Variables|Variables]] can be used if they contain numeric expressions, including an *array* of numbers separated by commas, in which case you can use an array index to select the desired number. | [[Variables|Variables]] can be used if they contain numeric expressions, including an *array* of numbers separated by commas, in which case you can use an array index to select the desired number. | ||
- | You can use either `=` or `==` (v8+) for testing for equality. | + | You can use either `=` or `==` for testing for equality. |
Operators and functions must be in uppercase to minimize conflict with variables. | Operators and functions must be in uppercase to minimize conflict with variables. | ||
Line 54: | Line 54: | ||
===== Variables ===== | ===== Variables ===== | ||
- | In numeric calculation fields, Variable Names are used without the `%` that are used in text token fields. Do not try to use tokens (like `%Variable%MyVar%`) in numeric calculation fields, just use MyVar by itself. The variable must contain a valid numeric value, or an expression (v8+) that evaluates to a valid numeric value. So for example, if MyVar contains a text value of `2*3`, then the calculation `4*MyVar` will return 24. | + | In numeric calculation fields, Variable Names are used without the `%` that are used in text token fields. Do not try to use tokens (like `%Variable%MyVar%`) in numeric calculation fields, just use MyVar by itself. The variable must contain a valid numeric value, or an expression that evaluates to a valid numeric value. So for example, if MyVar contains a text value of `2*3`, then the calculation `4*MyVar` will return 24. |
===== Screen Coordinates ===== | ===== Screen Coordinates ===== | ||
Line 112: | Line 112: | ||
{{:manual:window-frame-example-results-km-7.3.png?nolink|}} | {{:manual:window-frame-example-results-km-7.3.png?nolink|}} | ||
- | Some example expressions might be: | + | Some example expressions are: |
<code> | <code> |