$$math
Evaluate a mathematical expression
Usage​
{
"$$math": [/* operator */, /* operand 1 */, /* operand 2 ? */]
}
- OR
{
"$$math": [/* operand 1 */, /* operator */, /* operand 2 ? */]
}
"$$math(<operand1>,<operator>,[operand2])"
"$$math(<operator>,<operand1>,[operand2])"
"$$math(<operator>,[operand2]):{operand1}"
Returns​
number
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | array | Yes | Array of size 2/3 | |
operator | Enum | Described below | Yes | Operator |
operand1 | number | Yes | First operand | |
operand2 | number | Second operand |
Operators​
operator | Action | Example |
---|---|---|
+ , ADD | Addition | "$$math(2,+,3)" = 5 |
- , SUB , SUBTRACT | Subtraction | "$$math(5,-,3)" = 2 |
* , MUL , MULTIPLY | Multiplication | "$$math(2,*,3)" = 6 |
/ , DIV , DIVIDE | Division | "$$math(6,/,3)" = 2 |
// , INTDIV | Integer division | "$$math(7,//,3)" = 2 |
% , MOD , REMAINDER | Modulu | "$$math(7,%,3)" = 1 |
^ , ** , POW , POWER | Power | "$$math(2,^,3)" = 8 |
& , AND | Bit-wise AND | "$$math(6,&,3)" = 2 |
 | , OR | Bit-wise OR | "$$math(6,OR,3)" = 7 |
~ , XOR | Bit-wise XOR | "$$math(6,~,3)" = 5 |
<< , SHL | Shift left (bit-wise) | "$$math(6,>>,1)" = 3 |
>> , SHR | Shift right (bit-wise) | "$$math(6,<<,3)" = 48 |
MIN | Minimum | "$$math(MIN,4,2)" = 2 |
MAX | Maximum | "$$math(MAX,4,2)" = 4 |
SQRT | Square root | "$$math(SQRT,81)" = 9 |
ROUND | Round | "$$math(ROUND,4.6)" = 5 |
FLOOR | Floor | "$$math(FLOOR,4.6)" = 4 |
CEIL | Ceil | "$$math(CEIL,4.2)" = 5 |
ABS | Absolute | "$$math(ABS,-10)" = 10 |
NEG , NEGATE | Negation | "$$math(NEG,4)" = -4 |
SIG , SIGNUM | Sign Number | "$$math(SIG,-42)" = -1 |
Examples​
Input
Definition
Output
[4,2]
{ "$$math": ["+","$[0]","$[1]" ] }
6
[4,2]
{ "$$math": ["$[0]","+","$[1]" ] }
6
[4,2]
{ "$$math": ["$[0]","-","$[1]" ] }
2
[4,2]
{ "$$math": ["$[0]","*","$[1]" ] }
8
[4,2]
{ "$$math": ["$[0]","/","$[1]" ] }
2
[4,2]
{ "$$math": ["$[0]","//",3] }
1
[4,2]
{ "$$math": ["$[0]","%",3] }
1
[4,2]
{ "$$math": ["$[1]","^",3] }
8
[4,2]
{ "$$math": ["MIN","$[0]","$[1]" ] }
2
[4,2]
{ "$$math": ["MAX","$[0]","$[1]" ] }
4
{ "$$math": ["SQRT",81] }
9
{ "$$math": ["ROUND",4.6] }
5
{ "$$math": ["ROUND",4.66,1] }
4.7
{ "$$math": ["FLOOR",4.6] }
4
{ "$$math": ["FLOOR",4.66,1] }
4.6
{ "$$math": ["CEIL",4.2] }
5
{ "$$math": ["CEIL",4.22,1] }
4.3
{ "$$math": ["ABS",-10] }
10
[4,2]
{ "$$math": ["NEG","$[0]"] }
-4
-11
{ "$$math": ["SQRT",{ "$$math": ["$","^",2] }] }
11
[4,2]
"$$math(+,$[0],$[1])"
6
[4,2]
"$$math($[0],+,$[1])"
6
[4,2]
"$$math($[0],-,$[1])"
2
[4,2]
"$$math($[0],*,$[1])"
8
[4,2]
"$$math($[0],/,$[1])"
2
[4,2]
"$$math($[0],//,3)"
1
[4,2]
"$$math($[0],%,3)"
1
[4,2]
"$$math($[1],^,3)"
8
[4,2]
"$$math(MIN,$[0],$[1])"
2
[4,2]
"$$math(MAX,$[0],$[1])"
4
"$$math(SQRT,81)"
9
"$$math(SQRT):81"
9
"$$math(ROUND,4.6)"
5
"$$math(ROUND):4.6"
5
"$$math(ROUND,1):4.66"
4.7
"$$math(ROUND,4.66,1)"
4.7
"$$math(4.66,ROUND,1)"
4.7
"$$math(FLOOR,4.6)"
4
4.66
"$$math(FLOOR,1):$"
4.6
"$$math(CEIL,4.2)"
5
4.22
"$$math(CEIL,1):$"
4.3
"$$math(ABS,-10)"
10
[4,2]
"$$math(NEG,$[0])"
-4
"$$math(ROUND):$$math(10,/,4)"
3