Skip to main content

$$math

Evaluate a mathematical expression

Usage​

{ 
"$$math": /* `op1` / `op` / `array` (`[op1, op, op2]` / `[op, op1, op2]`) */,
"op1": /* BigDecimal */,
"op": /* Math operation (operator) */,
"op2": 0 /* BigDecimal */
}
"$$math(<op1>,<op>,[op2]):{input}"
note

Concrete values in the usage example are default values.

OR

{
"$$math": [/* operator */, /* operand 1 */, /* operand 2 ? */]
}

OR

{
"$$math": [/* operand 1 */, /* operator */, /* operand 2 ? */]
}

OR

"$$math(<operand1>,<operator>,[operand2])"

"$$math(<operator>,<operand1>,[operand2])"

"$$math(<operator>,[operand2]):{operand1}"

Returns​

number (BigDecimal)

Arguments​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryBigDecimalYesop1 / op / array ([op1, op, op2] / [op, op1, op2])
op1BigDecimalYesFirst operand
openum+/ -/*//////%/ ^/&/|/~/<</ >>/MIN/MAX/SQRT/ROUND/ FLOOR/CEIL/ABS/NEG/SIGYesMath operation (operator)
op2BigDecimal0Second operand or scale for ROUND/FLOOR/CEIL

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],+)"
4
[
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(3,&,1)"
1
[
4,
2
]
"$$math(6,AND,3)"
2
[
4,
2
]
"$$math(6,|,3)"
7
[
4,
2
]
"$$math(6,~,3)"
5
[
4,
2
]
"$$math(6,>>,1)"
3
[
4,
2
]
"$$math(6,<<,3)"
48
[
4,
2
]
"$$math(MIN,$[0],$[1])"
2
[
4,
2
]
"$$math(MAX,$[0],$[1])"
4
[
4,
2
]
"$$math(SQRT,81)"
9
[
4,
2
]
"$$math(SQRT):81"
9
[
4,
2
]
"$$math(SQRT):$$math($[0],^,2)"
4
[
4,
2
]
"$$math(ROUND,4.6)"
5
[
4,
2
]
"$$math(ROUND):4.6"
5
[
4,
2
]
"$$math(ROUND,1):4.66"
4.7
[
4,
2
]
"$$math(ROUND,4.66,1)"
4.7
[
4,
2
]
"$$math(4.66,ROUND,1)"
4.7
[
4,
2
]
"$$math(FLOOR,4.6)"
4
[
4,
2
]
"$$math(FLOOR):4.6"
4
[
4,
2
]
"$$math(FLOOR,1):4.66"
4.6
[
4,
2
]
"$$math(CEIL,4.2)"
5
[
4,
2
]
"$$math(CEIL):4.2"
5
[
4,
2
]
"$$math(CEIL,1):4.22"
4.3
[
4,
2
]
"$$math(ABS,-10)"
10
[
4,
2
]
"$$math(ABS):-10"
10
[
4,
2
]
"$$math(NEG,$[0])"
-4
[
4,
2
]
"$$math(NEG):$[0]"
-4
[
4,
2
]
"$$math(SIG):42"
1
[
4,
2
]
"$$math(SIGNUM):-42"
-1
[
4,
2
]
"$$math(SIG):0"
0
[
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": [
"%",
"$[0]",
"3"
]
}
1
[
4,
2
]
{
"$$math": [
"^",
"$[1]",
"3"
]
}
8
[
4,
2
]
{
"$$math": [
3,
"&",
1
]
}
1
[
4,
2
]
{
"$$math": [
6,
"&",
3
]
}
2
[
4,
2
]
{
"$$math": [
6,
"|",
3
]
}
7
[
4,
2
]
{
"$$math": [
6,
"XOR",
3
]
}
5
[
4,
2
]
{
"$$math": [
6,
">>",
1
]
}
3
[
4,
2
]
{
"$$math": [
6,
"<<",
3
]
}
48
[
4,
2
]
{
"$$math": [
"sqrt",
81
]
}
9
[
4,
2
]
{
"$$math": [
"min",
"$[0]",
"$[1]"
]
}
2
[
4,
2
]
{
"$$math": [
"max",
"$[0]",
"$[1]"
]
}
4
[
4,
2
]
{
"$$math": [
"round",
4.6
]
}
5
[
4,
2
]
{
"$$math": [
"round",
4.66,
1
]
}
4.7
[
4,
2
]
{
"$$math": [
"floor",
4.6
]
}
4
[
4,
2
]
{
"$$math": [
"floor",
4.66,
1
]
}
4.6
[
4,
2
]
{
"$$math": [
"ceil",
4.2
]
}
5
[
4,
2
]
{
"$$math": [
"ceil",
4.22,
1
]
}
4.3
[
4,
2
]
{
"$$math": [
"abs",
-10
]
}
10
[
4,
2
]
{
"$$math": [
"neg",
"$[0]"
]
}
-4
[
"abs",
-10
]
{
"$$math": "$"
}
10
[
4,
2
]
{
"$$math": [
"SIG",
42
]
}
1
[
4,
2
]
{
"$$math": [
"SIGNUM",
-42
]
}
-1
[
4,
2
]
{
"$$math": [
"SIG",
0
]
}
0
null
"$$decimal(2):$$math(1,*,0.987654321)"
0.99
null
"$$decimal(2,FLOOR):$$math(1,*,0.987654321)"
0.98