Operators
Arithmetic operators
Operators used to perform arithmetic operations.
$abs
Returns the absolute value of a number.
{ "$abs": "number" }
expry({ $abs: 1 }); // 1
expry({ $abs: -1 }); // 1
$add
Adds numbers together.
{ "$add": ["number", "number", "..."] }
expry({ $add: [1, 2, 3] }); // 6
expry({ $add: [-2, 4] }); // 2
$ceil
Returns the smallest integer greater than or equal to the specified number.
{ "$ceil": "number" }
expry({ $ceil: 1 }); // 1
expry({ $ceil: 7.8 }); // 8
expry({ $ceil: -2.8 }); // -2
$divide
Divides one number by another.
{ "$divide": ["number", "number"] }
expry({ $divide: [4, 2] }); // 2
expry({ $divide: [5, 2] }); // 2.5
$exp
Raises Euler's number to the specified exponent.
{ "$exp": "number" }
expry({ $exp: 0 }); // 1
expry({ $exp: 2 }); // 7.38905609893065
expry({ $exp: -2 }); // 0.1353352832366127
$floor
Returns the largest integer less than or equal to the specified number.
{ "$floor": "number" }
expry({ $floor: 1 }); // 1
expry({ $floor: 7.8 }); // 7
expry({ $floor: -2.8 }); // -3
$ln
Calculates the natural logarithm of a number.
{ "$ln": "number" }
expry({ $ln: 1 }); // 0
expry({ $ln: 10 }); // 2.302585092994046
$log
Calculates the log of a number in the specified base.
{ "$log": ["number", "base"] }
expry({ $log: [100, 10] }); // 2
$log10
Calculates the log base 10 of a number.
{ "$log10": "number" }
expry({ $log10: 1 }); // 0
expry({ $log10: 10 }); // 1
expry({ $log10: 100 }); // 2
$mod
Divides one number by another and returns the remainder.
{ "$mod": ["number", "number"] }
expry({ $mod: [5, 2] }); // 1
$multiply
Multiplies numbers together.
{ "$multiply": ["number", "number", "..."] }
expry({ $multiply: [2, 3] }); // 6
expry({ $multiply: [2, 2, 3] }); // 12
$pow
Raises a number to the specified exponent.
{ "$pow": ["number", "exponent"] }
expry({ $pow: [5, 0] }); // 1
expry({ $pow: [5, 2] }); // 25
expry({ $pow: [5, -2] }); // 0.04
$round
Rounds a number to a specified decimal place.
{ "$round": ["number", "place"] }
expry({ $round: [5.43, 0] }); // 5
expry({ $round: [5.43, 1] }); // 5.4
$sqrt
Calculates the square root of a positive number.
{ "$sqrt": "number" }
expry({ $sqrt: 25 }); // 5
expry({ $sqrt: 30 }); // 5.477225575051661
$subtract
Subtracts two numbers to return the difference.
{ "$subtract": ["number", "number"] }
expry({ $subtract: [5, 2] }); // 3
expry({ $subtract: [-2, 4] }); // -6
$trunc
Truncates a number to a specified decimal place.
{ "$trunc": ["number", "place"] }
expry({ $trunc: [5.43, 0] }); // 5
expry({ $trunc: [5.43, 1] }); // 5.4