Skip to main content

$$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​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of size 2/3
operatorEnumDescribed belowYesOperator
operand1numberYesFirst operand
operand2numberSecond operand

Operators​

operatorActionExample
+, ADDAddition"$$math(2,+,3)" = 5
-, SUB, SUBTRACTSubtraction"$$math(5,-,3)" = 2
*, MUL, MULTIPLYMultiplication"$$math(2,*,3)" = 6
/, DIV, DIVIDEDivision"$$math(6,/,3)" = 2
//, INTDIVInteger division"$$math(7,//,3)" = 2
%, MOD, REMAINDERModulu"$$math(7,%,3)" = 1
^, **, POW, POWERPower"$$math(2,^,3)" = 8
&, ANDBit-wise AND"$$math(6,&,3)" = 2
 | , ORBit-wise OR"$$math(6,OR,3)" = 7
~, XORBit-wise XOR"$$math(6,~,3)" = 5
<<, SHLShift left (bit-wise)"$$math(6,>>,1)" = 3
>>, SHRShift right (bit-wise)"$$math(6,<<,3)" = 48
MINMinimum"$$math(MIN,4,2)" = 2
MAXMaximum"$$math(MAX,4,2)" = 4
SQRTSquare root"$$math(SQRT,81)" = 9
ROUNDRound"$$math(ROUND,4.6)" = 5
FLOORFloor"$$math(FLOOR,4.6)" = 4
CEILCeil"$$math(CEIL,4.2)" = 5
ABSAbsolute"$$math(ABS,-10)" = 10
NEG, NEGATENegation"$$math(NEG,4)" = -4
SIG, SIGNUMSign 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